Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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)
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