ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I Address A Worksheet From A Cell Reference? (https://www.excelbanter.com/excel-programming/330029-how-do-i-address-worksheet-cell-reference.html)

georgef

How do I Address A Worksheet From A Cell Reference?
 
The following was generated by the macro recorder:

Sheets("project01").Select
Range("HL5:HZ8").Select
Selection.Copy
Sheets("Report").Select
Range("DR502:EF505").Select
ActiveSheet.Paste

I need to be able to select the sheet that I am copying things from based on
a cell value. For example, cell A1 could have "project06" or "project22" at
any given time when this macro runs. How do I accomplish this "indirect"
addressing? i.e., can I somehow use something like "Sheets("cell
A1").Select"? (I am not a VB programmer.)

Thank you.
George

Don Guillett[_4_]

How do I Address A Worksheet From A Cell Reference?
 
You could use this but it is very seldom necessary to select
Sheets(Range("f4").Value).Select

Sheets(Range("f4").Value). Range("HL5:HZ8").Copy _
Sheets("Report").range("DR502:EF505")

or if only values to copy (range must be the same size)

Sheets("Report").range("DR502:EF505").value= _
Sheets(Range("f4").Value). Range("HL5:HZ8").value
--
Don Guillett
SalesAid Software

"GeorgeF" wrote in message
...
The following was generated by the macro recorder:

Sheets("project01").Select
Range("HL5:HZ8").Select
Selection.Copy
Sheets("Report").Select
Range("DR502:EF505").Select
ActiveSheet.Paste

I need to be able to select the sheet that I am copying things from based

on
a cell value. For example, cell A1 could have "project06" or "project22"

at
any given time when this macro runs. How do I accomplish this "indirect"
addressing? i.e., can I somehow use something like "Sheets("cell
A1").Select"? (I am not a VB programmer.)

Thank you.
George




georgef

How do I Address A Worksheet From A Cell Reference?
 
Don - Works perfectly - thank you very much
George

"Don Guillett" wrote:

You could use this but it is very seldom necessary to select
Sheets(Range("f4").Value).Select

Sheets(Range("f4").Value). Range("HL5:HZ8").Copy _
Sheets("Report").range("DR502:EF505")

or if only values to copy (range must be the same size)

Sheets("Report").range("DR502:EF505").value= _
Sheets(Range("f4").Value). Range("HL5:HZ8").value
--
Don Guillett
SalesAid Software

"GeorgeF" wrote in message
...
The following was generated by the macro recorder:

Sheets("project01").Select
Range("HL5:HZ8").Select
Selection.Copy
Sheets("Report").Select
Range("DR502:EF505").Select
ActiveSheet.Paste

I need to be able to select the sheet that I am copying things from based

on
a cell value. For example, cell A1 could have "project06" or "project22"

at
any given time when this macro runs. How do I accomplish this "indirect"
addressing? i.e., can I somehow use something like "Sheets("cell
A1").Select"? (I am not a VB programmer.)

Thank you.
George





Don Guillett[_4_]

How do I Address A Worksheet From A Cell Reference?
 
glad to help

--
Don Guillett
SalesAid Software

"GeorgeF" wrote in message
...
Don - Works perfectly - thank you very much
George

"Don Guillett" wrote:

You could use this but it is very seldom necessary to select
Sheets(Range("f4").Value).Select

Sheets(Range("f4").Value). Range("HL5:HZ8").Copy _
Sheets("Report").range("DR502:EF505")

or if only values to copy (range must be the same size)

Sheets("Report").range("DR502:EF505").value= _
Sheets(Range("f4").Value). Range("HL5:HZ8").value
--
Don Guillett
SalesAid Software

"GeorgeF" wrote in message
...
The following was generated by the macro recorder:

Sheets("project01").Select
Range("HL5:HZ8").Select
Selection.Copy
Sheets("Report").Select
Range("DR502:EF505").Select
ActiveSheet.Paste

I need to be able to select the sheet that I am copying things from

based
on
a cell value. For example, cell A1 could have "project06" or

"project22"
at
any given time when this macro runs. How do I accomplish this

"indirect"
addressing? i.e., can I somehow use something like "Sheets("cell
A1").Select"? (I am not a VB programmer.)

Thank you.
George








All times are GMT +1. The time now is 02:42 PM.

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