How to automate with macro multiworksheet File using array variable?

  • Thread starter Thread starter GorKoUSA
  • Start date Start date
G

GorKoUSA

I created a file with multiple Worksheets and defined an Array:

Dim arrRtTab(1 To 12) As String

arrRtTab(1) = "MS"
arrRtTab(2) = "MW"
arrRtTab(3) = "MM"
arrRtTab(4) = "MU"
arrRtTab(5) = "MDS3"
arrRtTab(6) = "XS"
arrRtTab(7) = "XN"
arrRtTab(8) = "QN"
arrRtTab(9) = "QE"
arrRtTab(10) = "QS"
arrRtTab(11) = "NS"
arrRtTab(12) = "LI"

How can I access tabs of the file as variables for copy and paste
operation in my macro?
I need to copy from tab "LI" to tab"MS" or another tab pending results
of other computations.

Georgee
 
where x and y are your source and destination ranges, you should be able to do:

Worksheets(arrRtTab(12)).Range(x).Copy Worksheets(arrRtTab(1)).Range(y)
 
Thanks for your advice, it works nice but I have one more task.
How to select multiple tabs based on a certain condition for common
formatting tasks.
Syntax:
Worksheets(arrRtTab(1,2,3,4,5)).Select
Selection.Columns.AutoFit
ActiveWindow.Zoom = 75

Does not work

Georgee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top