ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to automate with macro multiworksheet File using array variable? (https://www.excelbanter.com/excel-programming/366020-how-automate-macro-multiworksheet-file-using-array-variable.html)

[email protected]

How to automate with macro multiworksheet File using array variable?
 
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


JMB

How to automate with macro multiworksheet File using array variabl
 
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)

" wrote:

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



GorKo

How to automate with macro multiworksheet File using array variabl
 
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


JMB wrote:
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)

" wrote:

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





All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com