Naming a cell

fahimip

New Member
Joined
Sep 27, 2006
Messages
35
I need to name a cell so that i can copy a range using the named cell as a reference.
the named cell will change every time the loop is completed.

heres what ive got so far:


Sub test()

Sheets("HD").Select
Range("G3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
mycell = ActiveCell
Range("E3:" & mycell).Select
Selection.copy
Range("A65536").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Selection.Paste

End Sub

Any ideas?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

This is one way you could reproduce the code you have:

Code:
Sub Test()
With Sheets("HD")
   Set myCell = .Range("G3").End(xlDown).Offset(-1,0)
   .Range("E3:" & myCell.Address).Copy Destination:=.Range("A65536").End(xlUp).Offset(1,0)
End With
End Sub

Best regards

Richard
 

Forum statistics

Threads
1,141,596
Messages
5,707,300
Members
421,502
Latest member
PULBAG

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