Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Better way to write this VBA

Is there a better way to choose the variables that I want?
Here's what I have so far and I need to expand it to 6
different choices rather than 3
'MemberInfo data for the GroupID
If ClassVar1 = "" And ClassVar2 = "" And ClassVar3 = "" _
And PlanVar1 = "" And PlanVar2 = "" And PlanVar3 = "" _
And BusVar1 = "" And BusVar2 = "" And BusVar3 = "" _
Then

strSQL = "Select SaCd, count(MemId)" & _
"From MemberInfoFacets " & _
"Where GroupID IN ('" & GroupVar1 & "','" &
GroupVar2 & "', '" & GroupVar3 & "') " & _
" AND MemDate = " & INDV & _
" GROUP BY SaCd"

'MemberInfo data for the GroupID and ClassID
ElseIf PlanVar1 = "" And PlanVar2 = "" And PlanVar3 = "" _
And BusVar1 = "" And BusVar2 = "" And BusVar3 = "" _
Then


strSQL = "Select SaCd, count(MemId)" & _
"From MemberInfoFacets " & _
"Where GroupID IN ('" & GroupVar1 & "','" &
GroupVar2 & "', '" & GroupVar3 & "') " & _
" And ClassID IN ('" & ClassVar1 & "','" &
ClassVar2 & "', '" & ClassVar3 & "') " & _
" AND MemDate = " & INDV & _
" GROUP BY SaCd"

'MemberInfo data for the GroupID and BusCat
ElseIf ClassVar1 = "" And ClassVar2 = "" And ClassVar3
= "" _
And PlanVar1 = "" And PlanVar2 = "" And PlanVar3 = "" _
Then

strSQL = "Select SaCd, count(MemId)" & _
"From MemberInfoFacets " & _
"Where GroupID IN ('" & GroupVar1 & "','" &
GroupVar2 & "', '" & GroupVar3 & "') " & _
" And BusCat IN ('" & BusVar1 & "','" &
BusVar2 & "', '" & BusVar3 & "') " & _
" AND MemDate = " & INDV & _
" GROUP BY SaCd"
'MemberInfo data for the GroupID and ClassID and PlanID
Else

strSQL = "Select SaCd, count(MemId)" & _
"From MemberInfoFacets " & _
"Where GroupID IN ('" & GroupVar1 & "','" &
GroupVar2 & "', '" & GroupVar3 & "') " & _
" And ClassID IN ('" & ClassVar1 & "','" &
ClassVar2 & "', '" & ClassVar3 & "') " & _
" And PlanID IN ('" & PlanVar1 & "','" &
PlanVar2 & "', '" & PlanVar3 & "') " & _
" AND MemDate = " & INDV & _
" GROUP BY SaCd"

End If

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write value vincent Excel Discussion (Misc queries) 1 March 18th 10 04:28 AM
how to write ‘  murugan Excel Discussion (Misc queries) 2 August 19th 08 01:45 PM
How do I write X^2? webb New Users to Excel 2 October 15th 07 08:21 AM
How do you write a T with a bar on it? sheezyspearean Excel Discussion (Misc queries) 1 September 15th 05 03:43 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"