Solved

dO LOOP PROBLEM

Posted on 2013-12-20
4
231 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now