Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Selecting dynamic range of columns to format in macro.

Hello,

I created a simple macro which exports data to excel and formats it a little.

I have a problem with creating dynamic ranges of columns that should be formatted.

Currently I am simply using:

XLSheet.Range("BK1:BN1").Cells.Font.Color = RGB(255,255,255)

I want to get rid oh hard coded BK1 BN1 range and just create variables which will create range...

How to do so?

BR,

Kuba

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try creating a variable for the range (vMyRange: BK1:BN1) and retrieve and use the value of that variable in the macro. Something like:

myRange = ActiveDocument.Variables("vMyRange").GetContent.String

XLSheet.Range(myRange).Cells.Font.Color = RGB(255,255,255)


talk is cheap, supply exceeds demand
Not applicable
Author

I guess I did not describe this properly.

I want to define initial column, and then to be able automatically change it via variable.

Example:

vRangeStart = "A1"

vRangeEnd =  "A3"

Then next range Start: vRangeStart+[3 rows to the right] = A4

Then next range End:   vRangeEnd+[3 rows to the right] = A6