Questions tagged [select-case]

164 questions
0
votes
2 answers

Single line VBScript Select Case with multiple statements: eg: Case 0: x=a y=b

I'm randomly selecting a flag and corresponding country using VBScript. Because of the way I'm generating the code (programmatically), each Case statement will end up on a single line. I know to use the colon (":") after the Case x: to keep the…
Kringle
  • 115
  • 1
  • 5
0
votes
1 answer

Vba to Auto filter based on multiple columns

I'm working on a project and I need your help I need Vba code to Auto filter and count items based on multiple columns For example I have So the result should be And so on for all the range I tried Auto filter then select case code for the…
0
votes
1 answer

VBA code for multiple if statements within an Array

I am trying to split the array in column B which is separated by commas and then look for each item and if the condition is satisfied then publish something in column C. I have lot of scenarios with combination of both AND/OR conditions. At the end…
Wafee77
  • 3
  • 3
0
votes
1 answer

Select Case Statement with an Insert

I am a little bit confused because of my SQL. I am trying to use the "Select Case Statement" to validate if a specific association exists, when existing it shouldn't do the insert statement. However, I can't use an insert statement in the "Then"…
Xplosio
  • 13
  • 2
  • 7
0
votes
1 answer

VB Case condition is true but, action is not executed

I've write the following VB code. Dim qu1, qu2, facroredload, bx, iterations, q3, err As Double bx = 0.1 qu1 = "constant" For iterations = 0 To 10000 qu2 = "constant" * bx q3 = qu1 + qu2 facroredload = "constant" / bx ^…
user4129763
0
votes
1 answer

Case statement nested in WITH Statement not selecting a case

I am trying to set cell "H2" to either "Shift 1" , "Shift 2" or "Shift 3" depending on the inputted time value found in Cell D2 of my workbook, here is a screenshot example: So Cell H2 is Shift 1 because it's within a Timevalue of Case…
Handreen
  • 77
  • 11
0
votes
1 answer

select case with H2 database asking to group by column

When I use HQL to query my database, this requests works fine and return the good data : select case when activityjp0_.status<>'CLOSED' and (activityjp0_.user_id is null) then 'UNASSIGNED' else case …
0
votes
1 answer

VBA Select case 1 to 100 only taking 1

I'm trying to make a select case that identifies if a number is lower than 0, 1 to 100 or greater than 100, the thing is that is just doesn't work. Here's my code: If IsNumeric(TxtTemp.Text) Then Select Case TxtTemp.Text Case Is <= 0 …
0
votes
1 answer

Is an array inside a select case statement possible?

I just want to know if it is possible for me to assign an array and use it as a qualifier inside a case statement? Sub AccountCopy() Dim Criteria1 As Variant Dim Criteria2 As Variant Dim Acct As Variant Dim NR As Integer Criteria1 =…
0
votes
1 answer

Select Case with Complex Return Value (VBA 2007)

Using Excel 2007 and inexperienced with VBA. I am trying to create a text generator where, given a particular type of entry, it returns a string of text AND a number of corresponding cells. I have a lot of data to combine and somewhat complex text…
0
votes
1 answer

Why do I get random/wrong output from VBA Select Case?

I have a problem with the code below. I've just started to learn this and when I did a simple exercise, it turned out the code is working really randomly. Sometime nothing is done, sometime only one case is being selected but never the right…
JakubTracz
  • 27
  • 2
  • 8
0
votes
0 answers

VBA: How to handle runtime error 13 with multiple inputs caused by auto-completion

I try to implement a feature that automatically creates a comment attached to a cell, if a certain letter was typed into this cell by a user. The switch-case statement works fine as long as I don't use autocompletion, e.g. I type in an "A" and want…
greenfield
  • 79
  • 1
  • 9
0
votes
3 answers

How to use condition in T-SQL

I'm trying to use a select case in order to either use a where condition or not in a sql query. But it does not work and I can use some help how to solve this if possible DECLARE @CategoryID Int SET @CategoryID = 0 SELECT * FROM SomeTable CASE WHEN…
MTplus
  • 2,077
  • 4
  • 34
  • 51
0
votes
0 answers

How to fix VBA FOR EACH freezing at certain pages and not other pages of Word docx?

ISSUE: How to fix a Word VBA FOR EACH subroutine that seeks to insert a comment at each tracked change and, yet, will freeze VBA/Word at certain pages of a document and not other pages. The below code works on some documents throughout the entire…
0
votes
2 answers

Select Case with multiple "Like" conditions

I am trying to reduce a large If statement by creating a smaller Case statement. I am not sure what I am doing wrong, but here is what I have so far. It is similar to this post, but doesn't address the multiple situations and one result of my…
A Cohen
  • 458
  • 7
  • 26