Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select all Months...VB problems

Hi everyone,

I'm trying to build a Macro that will do selections on all the months (starting from Jan) untill the month that

have just been selected by the user.

i.e when the user selecting 'MAR' then the macro will select JAN+FEB+MAR.

I strarted writing it :

sub Select_Month
set val = ActiveDocument.Variables("maxMonth")

////// I build a Variable that holds the max selected month

a = val.GetContent.String

for i=1 to a

ActiveDocument.Fields("Month").Select i

???

next

end sub

Tips anyone? I should build an array somehow?

Thanks you very much

david

1 Solution

Accepted Solutions
Not applicable
Author

Well, you will always be selecting January and it looks like your months are just numbers. Something like:

sub Select_Month
set val = ActiveDocument.Variables("maxMonth")
a = val.GetContent.String
ActiveDocument.Fields("Month").Select i
for i=2 to a
ActiveDocument.Fields("Month").ToggleSelect i
next
end sub


View solution in original post

3 Replies
Not applicable
Author

Well, you will always be selecting January and it looks like your months are just numbers. Something like:

sub Select_Month
set val = ActiveDocument.Variables("maxMonth")
a = val.GetContent.String
ActiveDocument.Fields("Month").Select i
for i=2 to a
ActiveDocument.Fields("Month").ToggleSelect i
next
end sub


Not applicable
Author

excellent!

Not applicable
Author

Hi.

Try this.


sub Select_Month
set val = ActiveDocument.Variables("maxMonth")
a = val.GetContent.String
ActiveDocument.Fields("Month").Select "<="&a
end sub