Do Until Loop

Carl Clements

Board Regular
Joined
Jun 13, 2008
Messages
95
I have the below code that works along a spreadsheet (inserting 1 row per day) and then processes a transaction at the end (with the Call IA_Adjustment sub).

After a weekend, it currently inserts 3 rows and Calls 'IA_Adjustment' after each row. However, I want it to only Call 'IA_Adjustment' after the third row is inserted.

The variable that stores the number of rows is 'I'

I think I need another Do Until Loop but I'm not sure where it would go. Can anybody advise?

[D8].Select
Do Until Trim(ActiveCell.Value) = ""
Cusip = Trim(ActiveCell.Value)

If Len(Cusip) <> 9 Then

MsgBox "Please check the cusip is correct in cell " & ActiveCell.Address, vbInformation, "Cusip Incorrect"

End

Else

End If

ActiveCell.Offset(1, 3).Select


Do Until Trim(ActiveCell.Value) = ""

Account = Trim(ActiveCell.Value)
StoreCol = ActiveCell.Column

If Len(Account) <> 11 Then

MsgBox "Please check the Account is correct in cell " & ActiveCell.Address, vbInformation, "Account Incorrect"
End

Else

'Stores the cell location of the Account

StoreLocation = ActiveCell.Address

Call ZINTS

Cells(NewRow, StoreCol).Select

Call Data_Into_Spreadsheet

Call IA_Adjustment

Else

End If

Range(StoreLocation).Select
ActiveCell.Offset(0, 5).Select


End If

Loop

ActiveCell.Offset(-1, -1).Select

Loop

Next I

MsgBox "Finished, please check for any errors", vbInformation, "Finished"
[C1].Select
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,527
Messages
6,179,337
Members
452,907
Latest member
Roland Deschain

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