Solved

dO LOOP PROBLEM

Posted on 2013-12-20
4
239 Views
Last Modified: 2013-12-20
Hi Guys, I have a Do Loop problem where a series of If statements populates certain Cells. However, there is some problem with this bit of code and its over-running:

While Cells(i, 5).Value <> ""

i = i + 1

If Cells(i, 53).Text <> "#N/A" Then
Cells(i, 30).Value = "On dashboard - non-validated trade"
Cells(i, 31).Value = "BAU - Dashboard"
Cells(i, 33).Value = 0
Cells(i, 34).Value = "GL Incorrect"
See my attchment.
0
Comment
Question by:Justincut
  • 2
  • 2
4 Comments
 

Author Comment

by:Justincut
ID: 39732345
Here it is
Dummy-Rec-10.xlsm
0
 
LVL 35

Expert Comment

by:mvidas
ID: 39732378
Hi Justin,

Put the i=i+1 line just before the Wend line (at the end of the loop); it checks column E of a row, but then increases the row number before your code runs it.

Matt
0
 

Author Comment

by:Justincut
ID: 39732465
Hi Matt, do you mean after the  "End iF" statement?

Like this:


ElseIf Cells(i, 11).Value = "500000013" Then

Cells(i, 30).Value = "Manual Jnl - 1202566/dchet5 - CARFAX P&L CORRECTION"

Cells(i, 21).Value = "92,293.21"


Cells(i, 31).Value = "Manual Jnl (STD)"


Cells(i, 32).Value = "JC"
Cells(i, 33).Value = "0"
Cells(i, 34).Value = "0"

Cells(i, 36).Value = "14/03/2012"
End If
i = i + 1
Wend
0
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 39732469
Yep, so that way when it runs through your loop it only interacts with the row it checked. At the end, it moves to the next row, and checks it then.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Dependent Data Validation 12 43
Excel (Office365) chart 9 49
Need Help with Mapping and Toggling 3 20
Copy column before Column A using a macro 6 13
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question