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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,764
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:

dig475

New Member
Joined
Jun 23, 2009
Messages
7
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?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,984
Messages
5,767,440
Members
425,414
Latest member
chwein

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
Top