ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro (https://www.excelbanter.com/excel-discussion-misc-queries/241221-macro.html)

cvgairport

Macro
 
Hi everyone -

I have a spreadsheet with multiple tabs. I have a need at the start of the
month to copy several sections on different tabs to other places on those
same tabs. Right now the macro I developed copies a single section to
another place:

Range("A17:P30") = Range("A2:P15").Value

I would like to stack these types of commands within a single macro to do
the copying of the various sections but I don't know how to, within the
macro, switch tabs.

Any help would be appreciated.

Amy

Dave Peterson

Macro
 
Your code doesn't really copy the values--it just assigns them.

And you don't have to select/activate a worksheet to work on it.

worksheets("sheet999").range("A17:P30").value _
= worksheets("sheet888").range("a2:p15").value

If you want to copy, er, assign a specific range from a specific sheet, you
could activate the new sheet and then use something like:

ActiveSheet.range("A17:P30").value _
= worksheets("myMasterSheetNameHere").range("a2:p15" ).value



cvgairport wrote:

Hi everyone -

I have a spreadsheet with multiple tabs. I have a need at the start of the
month to copy several sections on different tabs to other places on those
same tabs. Right now the macro I developed copies a single section to
another place:

Range("A17:P30") = Range("A2:P15").Value

I would like to stack these types of commands within a single macro to do
the copying of the various sections but I don't know how to, within the
macro, switch tabs.

Any help would be appreciated.

Amy


--

Dave Peterson

JCS

Macro
 
Hi Amy,

To programatically switch tabs, try: Sheets("Sheet2").Select Substitute
Sheet2 with the name(s) of your sheet tabs. Please press Yes if this helped
you.

JCS

"cvgairport" wrote:

Hi everyone -

I have a spreadsheet with multiple tabs. I have a need at the start of the
month to copy several sections on different tabs to other places on those
same tabs. Right now the macro I developed copies a single section to
another place:

Range("A17:P30") = Range("A2:P15").Value

I would like to stack these types of commands within a single macro to do
the copying of the various sections but I don't know how to, within the
macro, switch tabs.

Any help would be appreciated.

Amy


cvgairport

Macro
 
Thanks! it appears to work!

"JCS" wrote:

Hi Amy,

To programatically switch tabs, try: Sheets("Sheet2").Select Substitute
Sheet2 with the name(s) of your sheet tabs. Please press Yes if this helped
you.

JCS

"cvgairport" wrote:

Hi everyone -

I have a spreadsheet with multiple tabs. I have a need at the start of the
month to copy several sections on different tabs to other places on those
same tabs. Right now the macro I developed copies a single section to
another place:

Range("A17:P30") = Range("A2:P15").Value

I would like to stack these types of commands within a single macro to do
the copying of the various sections but I don't know how to, within the
macro, switch tabs.

Any help would be appreciated.

Amy



All times are GMT +1. The time now is 03:39 AM.

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