View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
ramzi ramzi is offline
external usenet poster
 
Posts: 24
Default macro to copy only range with data

Hi Mike,

my original macro is below...

Range("d9:j15,O9:O15").Copy

lastrow = Sheets("sale").Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
Sheets("sale").Range("A" & lastrow).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


but my data not always from row 9 to 15 , sometime only at row 9 or only at
row 9 to 10...
I need macro to pick up the watever written in row form 9 to 15.. if row 15
is blank the macro will select row 9 to 14 and do copy paste.

thanks










"Mike H" wrote:

Hi,

Try this

Range("A1:B" & Range("B6").End(xlUp).Row).Copy

Note B6 isn't a typo, this works for A1 - B5

Mike

"ramzi" wrote:

HI...

my data range area is from A1:B5.....
How I going to copy only the range with data... ( my range of data keep on
changing but within A1:B5.

e.g the data is located at A1:B2, so the macro will ignore A3:B5.

rgds