Progress Bar

S

Striker

I am trying to create a progress bar, but it needs to be after LastRow is
defined, so not sure where I should put my bar to go along with this For
Each Loop? So Basically each time I loop thru the FOR EACH, I would like to
update the progress bar. I must be putting it in the wrong place as it goes
thru the lop twice.

Any help is greatly appriciated

~~~~~~~~ProgressBar1~~~~~~~~~~~~~~~~~~
ProgressBar1.Min = 0
ProgressBar1.Max = LastRow

For i = 0 To LastRow
DoEvents
ProgressBar1.Value = i
Next i
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



~~~~~CURRENT CODE~~~~~~~~~~~~~~~~~~~~~~~~~~
LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Set rng = Range("A2:A" & LastRow)

For Each rCell In rng.Cells
With rCell
.Offset(0, 5).Value = Trim(.Value) _
& Trim(.Offset(0, 3).Value) & Trim(lSerdate) & Trim(lCounter)
sLosdf = .Offset(0, 0)
sLdan = .Offset(0, 1)
sReason = .Offset(0, 2)
sUID = .Offset(0, 5)
sTel =(.Offset(0, 3).Value)

lCounter = lCounter + 1

End With
Next rCell
lCounter = lCounter - 1
 
M

moon

Striker said:
I am trying to create a progress bar, but it needs to be after LastRow is
defined, so not sure where I should put my bar to go along with this For
Each Loop? So Basically each time I loop thru the FOR EACH, I would like
to update the progress bar. I must be putting it in the wrong place as it
goes thru the lop twice.

Any help is greatly appriciated

~~~~~~~~ProgressBar1~~~~~~~~~~~~~~~~~~
ProgressBar1.Min = 0
ProgressBar1.Max = LastRow

For i = 0 To LastRow
DoEvents
ProgressBar1.Value = i
Next i
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



~~~~~CURRENT CODE~~~~~~~~~~~~~~~~~~~~~~~~~~
LastRow = Cells(Rows.Count, "A").End(xlUp).Row

Set rng = Range("A2:A" & LastRow)

For Each rCell In rng.Cells
With rCell
.Offset(0, 5).Value = Trim(.Value) _
& Trim(.Offset(0, 3).Value) & Trim(lSerdate) & Trim(lCounter)
sLosdf = .Offset(0, 0)
sLdan = .Offset(0, 1)
sReason = .Offset(0, 2)
sUID = .Offset(0, 5)
sTel =(.Offset(0, 3).Value)

lCounter = lCounter + 1

End With
Next rCell
lCounter = lCounter - 1



Hi,

Maybe you can find a way to let the progressbar's value increase together
with lCounter

lCounter = lCounter +1
DoEvents
ProgressBar1.Value = lCounter


You're increasing something anyway, so use it and update the pb every time a
cell is entered.
 
S

Striker

Hi,

Maybe you can find a way to let the progressbar's value increase together
with lCounter

lCounter = lCounter +1
DoEvents
ProgressBar1.Value = lCounter


You're increasing something anyway, so use it and update the pb every time
a cell is entered.


Yea, that's my problem finding a way to increment it inside a For Each Loop
and not loop thru the loop twice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top