How do I make my Macro stop copying the title row too??

dig475

New Member
Joined
Jun 23, 2009
Messages
7
Hi,
In my macro, I am copying and pasting a value, this is the code:

If Cells(i, 7).value > 0 Then
With Cells(i, 7).Select
Selection.Copy
Cells(i, 9).Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Unfortunately, I can not figure out how to copy the value ONLY if it is a number (rather than the title as well).

Does this make sense? If yes, can you help?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Does this make sense?

Not really. For starters, you haven't posted all of your code. What value does i hold? Why is your code copying the title row? Have your tried stepping through your code using F8?

Also, the code you posted could be condensed to:

Code:
With Cells(i,7)
If .Value > 0 Then Cells(i,9) = .Value
End With
 
Last edited:
Upvote 0
Here is all of my code:
'How many rows do we have today?
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
'Loop through each row
For i = 17 To FinalRow
'check to see if column 7<0
'if it is <0, then copy the cell and paste to column 8
If Cells(i, 7).Value < 0 Then
With Cells(i, 7).Select
Selection.Copy
Cells(i, 8).Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
End If
'check to see if column 7>0
'if it is <0, then copy the cell and paste to column 9
If Cells(i, 7).Value > 0 Then
With Cells(i, 7).Select
Selection.Copy
Cells(i, 9).Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
End If
Next i
Where i is the row, does this make more sense?
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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