#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
DP7 DP7 is offline
external usenet poster
 
Posts: 54
Default Macro Help

I have a macro that copies values from one Worksheet (A) in a Workbook to a
range in another Worksheet (B) in the same Workbook. Some times the values in
workbook A will be empty and the Macro copies over a blank /Zero value. I
would like to modify the macro in such a way that If the Cell In worksheet A
is empty that zero value will not be copied over to worksheet (B) & That the
next value that is pasted in Workbook B will be put below the last value. In
other words I would like no spaces to be left in the range. Below is an
excerpt of my Macro.


Sub CVSCopy()
'
' CVSCopy Macro

Sheets(4).Range("C20").Value = Sheets(2).Range("H6").Value
Sheets(4).Range("C21").Value = Sheets(2).Range("H7").Value
Sheets(4).Range("C22").Value = Sheets(2).Range("H10").Value
Sheets(4).Range("G20").Value = Sheets(2).Range("J6").Value
Sheets(4).Range("G21").Value = Sheets(2).Range("J7").Value
Sheets(4).Range("G22").Value = Sheets(2).Range("J10").Value
Sheets(4).Range("G24").Value = Sheets(2).Range("L39").Value
Sheets(4).Range("G25").Value = Sheets(2).Range("L46").Value
Sheets(4).Range("C28").Value = Sheets(2).Range("H15").Value
Sheets(4).Range("C29").Value = Sheets(2).Range("H28").Value



  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,345
Default Macro Help

Add a test before your copy line:

Sub CVSCopy()
'
' CVSCopy Macro

If Sheets(2).Range("H6").Value < "" Then _
Sheets(4).Range("C20").Value = Sheets(2).Range("H6").Value
If Sheets(2).Range("H7").Value < "" Then _
Sheets(4).Range("C21").Value = Sheets(2).Range("H7").Value
If Sheets(2).Range("H10").Value < "" Then _
Sheets(4).Range("C22").Value = Sheets(2).Range("H10").Value
If Sheets(2).Range("J6").Value < "" Then _
Sheets(4).Range("G20").Value = Sheets(2).Range("J6").Value
If Sheets(2).Range("J7").Value < "" Then _
Sheets(4).Range("G21").Value = Sheets(2).Range("J7").Value
If Sheets(2).Range("J10").Value < "" Then _
Sheets(4).Range("G22").Value = Sheets(2).Range("J10").Value
If Sheets(2).Range("L39").Value < "" Then _
Sheets(4).Range("G24").Value = Sheets(2).Range("L39").Value
If Sheets(2).Range("L39").Value < "" Then _
Sheets(4).Range("G25").Value = Sheets(2).Range("L39").Value
If Sheets(2).Range("H15").Value < "" Then _
Sheets(4).Range("C28").Value = Sheets(2).Range("H15").Value
If Sheets(2).Range("H28").Value < "" Then _
Sheets(4).Range("C29").Value = Sheets(2).Range("H28").Value
End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"DP7" wrote in message
...
I have a macro that copies values from one Worksheet (A) in a Workbook to a
range in another Worksheet (B) in the same Workbook. Some times the values
in
workbook A will be empty and the Macro copies over a blank /Zero value. I
would like to modify the macro in such a way that If the Cell In worksheet
A
is empty that zero value will not be copied over to worksheet (B) & That
the
next value that is pasted in Workbook B will be put below the last value.
In
other words I would like no spaces to be left in the range. Below is an
excerpt of my Macro.


Sub CVSCopy()
'
' CVSCopy Macro

Sheets(4).Range("C20").Value = Sheets(2).Range("H6").Value
Sheets(4).Range("C21").Value = Sheets(2).Range("H7").Value
Sheets(4).Range("C22").Value = Sheets(2).Range("H10").Value
Sheets(4).Range("G20").Value = Sheets(2).Range("J6").Value
Sheets(4).Range("G21").Value = Sheets(2).Range("J7").Value
Sheets(4).Range("G22").Value = Sheets(2).Range("J10").Value
Sheets(4).Range("G24").Value = Sheets(2).Range("L39").Value
Sheets(4).Range("G25").Value = Sheets(2).Range("L46").Value
Sheets(4).Range("C28").Value = Sheets(2).Range("H15").Value
Sheets(4).Range("C29").Value = Sheets(2).Range("H28").Value






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 Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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