Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Help with macro

I am having a problem with a Macro.

I have a set of part numbers in cells F7:M7. I want to Copy/Paste
SpecialValues down to the next available line at the bottom of the
worksheet, (currently line 20) so I want to paste F7:M7 into the blank cells
F20:M20.

Excel does this fine, and the macro records fine. But when it runs it does
not know which data to use. I think the problem is that the location of the
next available line keeps changing (plus one) each time I try to run the
macro.

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Help with macro

Try this:

Sub michael()
Dim r As Range, r2 As Range
Set r = Range("F7:M7")
n = Cells(Rows.Count, "F").End(xlUp).Row + 1
Set r2 = Range("F" & n)
r.Copy r2
End Sub
--
Gary''s Student - gsnu200814
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Help with macro

You can shorten your macro a bit...

Sub Mike()
Range("F7:M7").Copy Cells(Rows.Count, "F").End(xlUp).Offset(1)
End Sub

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Try this:

Sub michael()
Dim r As Range, r2 As Range
Set r = Range("F7:M7")
n = Cells(Rows.Count, "F").End(xlUp).Row + 1
Set r2 = Range("F" & n)
r.Copy r2
End Sub
--
Gary''s Student - gsnu200814


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Help with macro

Many thanks, 'Gary's student' and Rick.

Mike

"Rick Rothstein" wrote:

You can shorten your macro a bit...

Sub Mike()
Range("F7:M7").Copy Cells(Rows.Count, "F").End(xlUp).Offset(1)
End Sub

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Try this:

Sub michael()
Dim r As Range, r2 As Range
Set r = Range("F7:M7")
n = Cells(Rows.Count, "F").End(xlUp).Row + 1
Set r2 = Range("F" & n)
r.Copy r2
End Sub
--
Gary''s Student - gsnu200814



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Help with macro (II)

The 'offset' command works fine, but i am having difficulty embedding it into
the "Paste Special values" macro which I recorder earlier. There is
something I am not getting about specifying the destination range.

Here is the code that I want to modify so that the destination range is the
'offset' range rather than "A20":

Sub PasteSpecial()
Range("A4:E4").Select
Application.CutCopyMode = False
Selection.Copy
Range("A20").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

Thanks again.

Mike

"MichaelRobert" wrote:

Many thanks, 'Gary's student' and Rick.

Mike

"Rick Rothstein" wrote:

You can shorten your macro a bit...

Sub Mike()
Range("F7:M7").Copy Cells(Rows.Count, "F").End(xlUp).Offset(1)
End Sub

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Try this:

Sub michael()
Dim r As Range, r2 As Range
Set r = Range("F7:M7")
n = Cells(Rows.Count, "F").End(xlUp).Row + 1
Set r2 = Range("F" & n)
r.Copy r2
End Sub
--
Gary''s Student - gsnu200814





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 to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:06 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"