Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set a range in a Macro to copy

Hi,

I need copy a cell into a range of cells in another column, where the
range is determined by the height of another column (row value of the
last non-blank character)

The following code copies the contents of cell D1 into the range
"E1","E42"). When I try to replace 42 with the value of the Match
function it does not work.

Range("D1").Select
Selection.Copy
' Match("",B:B,1) evaluates to 42 in the spread sheet, the last
non-blank row in Column B
' When used in to select the range I get a compile error.
' How do I fix this?????????
'
' Range("E1", "H" & Match("",B:B,1)).Select
'
Range("E1", "E" & 42).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Thanks,

MikeC

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Set a range in a Macro to copy

If MATCH() will work in the worksheet, then put it in a cell (say Z100).
Then in VBA try:

Range("E1", "H" & Range("Z100").Value).Select

Have not tested this. May not work, but worth a try.

--
Gary''s Student


"MikeC" wrote:

Hi,

I need copy a cell into a range of cells in another column, where the
range is determined by the height of another column (row value of the
last non-blank character)

The following code copies the contents of cell D1 into the range
"E1","E42"). When I try to replace 42 with the value of the Match
function it does not work.

Range("D1").Select
Selection.Copy
' Match("",B:B,1) evaluates to 42 in the spread sheet, the last
non-blank row in Column B
' When used in to select the range I get a compile error.
' How do I fix this?????????
'
' Range("E1", "H" & Match("",B:B,1)).Select
'
Range("E1", "E" & 42).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Thanks,

MikeC


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro copy from range puiuluipui Excel Discussion (Misc queries) 3 October 19th 09 05:03 PM
macro to copy range Frank Situmorang[_2_] Excel Worksheet Functions 7 June 3rd 08 09:54 AM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
Macro to copy a range PCOR Excel Programming 4 December 27th 03 03:21 PM
Macro to copy a range jamesa Excel Programming 2 September 19th 03 12:33 PM


All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"