Newbie needs looping help. :)

krice1974

Active Member
Joined
Jul 3, 2008
Messages
422
Hey there all, thanks in advance for any help to get me over an early vba hurdle. I'm trying to loop through pasted trade confirmations from my broker. Relevant info:
-rows 1-7 are above my dataset area, command buttons etc.
-column 2 is "Buy/Sell".
-It imports cleanly except for misc notes on dividends etc that I wish to delete to just keep a clean dataset of trade confirmations.

Since I only want trade records and want to eliminate other notes etc that paste over from the copied info, looking for either "is empty" or <> buy or sell seems to be the best way to do it. It doesn't work though... it deletes about half of them. When I run it again, it then deletes the remainder. What am I doing wrong???

Here's my code:

Sub Schwab_Trades_Process()

'Click immediately after copying schwab trade confirmations

ActiveSheet.Paste

Selection.UnMerge
Selection.WrapText = False

Dim rowcnt As Integer
rowcnt = Selection.Rows.Count

Dim loopcnt As Integer
For loopcnt = 8 To rowcnt
If IsEmpty(Cells(loopcnt, 2)) Then
Cells(loopcnt, 2).EntireRow.Delete
End If
Next loopcnt

End Sub

Many thanks in advance...

Kevin
 
Erik, thanks. I since got it. I'm learning that vba can be sensitive to copy/pasted vs typed code for possible errors. But I'm up and running now, thanks for your help...
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,215,584
Messages
6,125,669
Members
449,248
Latest member
wayneho98

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