Do while Loop, and For next can use together in sheets?

ping0775

New Member
Joined
Jul 18, 2022
Messages
40
Office Version
  1. 2007
Platform
  1. Windows
If Target.Column = 23 Then
Dim counta, r As Long
countt = Sheets("InvoiceDatabase").Cells(Rows.count, "A").End(xlUp).Row
t = 3
Do While t <= countt

invno = Sheet4.Range("b" & t).Value
invno = Format(StrConv(invno, vbUpperCase))
For r = 3 To Sheet19.Range("c10").End(xlUp).Row
For x = 1 To Len(Sheet19.Cells(r, 3))
a = invno.TextLength
If UCase(Mid(Sheet19.Cells(r, 3), x, a)) = invno Then
paid = Format(Sheet19.Cells(r, "F"), "####0.00") 'Paid
End If
Next x
Next r
Sheet4.Range("ai" & t).Value = Sheet4.Range("w" & t).Value
t = t + 1
Loop
End If

Hi above code apply in Sheets('InvoiceDatabase")
the lopp in Do while work fine.
but when i want to extract the value in sheet19 , it doesn't work anymore
For r = 3 To Sheet19.Range("c10").End(xlUp).Row
how to fixed this?

how to create second loop in another sheets to extract the value
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Do you actually have a Sheet with the name "Sheet19", or are you trying to reference by sheet index?

If you look in the VBA Project explorer, it will show both the Sheet indexes and names (indexes are first and name is in parentheses):

1664194442632.png
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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