referring to a cell in anothjer sheet

alberta

New Member
Joined
May 17, 2004
Messages
14
I'm stiill a newbie, and I have been struggling with the syntax to make this work and hope that someone can help my through it.

The final set of spreadsheets generated by some VBA code will need to have a bit of text changed each time that it is run. The user can open the “text_copy” sheet in the workbook and make whatever changes to cell A1 and A2, and I was hoping that the VBA code would display it in B14 AND B15 of the new sheets.

This isn’t working out too well for me.

Code:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
.Range("B14") = text_copy!$A$1
.Range("B15") = text_copy!$A$2
End With
Next

Any suggestions would be appreciated.

Albert
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
Try:

Code:
 Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
    .Range("B14") = sheets("text_copy").Range("A1").value
    .Range("B15") = sheets("text_copy").Range("A2").value
End With
Next
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,019
Messages
5,834,984
Members
430,331
Latest member
Syed Yasir Hannan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top