How copy range of data based on header name

raghavat

New Member
Joined
Jul 20, 2011
Messages
2
TRYING TO COPY RANGE OF DATA BASEDON HEADER
Dim r, a As Long
a = 1
Do While Sheets("Address123").Cells(a, 1).Value > 0
r = r + 1
a = a + 1
Loop
Sheets("Address123").Select
Address = WorksheetFunction.Match("Address", Rows("1:1"), 0)

Sheets("Address123").Select
Range(" Address:a").Select (error)
Selection.Copy
Sheets("Loc").Range("D1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

While trying like dis facing error.can anyone help me out?
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the board raghavat,

The problem is that you want to use the variables' values but because they are in quotes "" the are just interpreted as the string " Address:a".
So instead of Range(" Address:a").Select use Cells(a, Address).Select
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,856
Members
452,948
Latest member
UsmanAli786

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
Back
Top