Do While Loop VBA

anand3dinesh

Board Regular
Joined
Dec 19, 2019
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Dear Friends,

i have this below code for Do While Loop. when i run this code a attached error occurs, i have no idea why variable "d" will update to value 3 even i have only 2 rows of data.
Any Help please?

Do While error.JPG

Do While Cells(d, 2).Value <> ""

Set Audit = Application.Workbooks.Open(UI.Range("B" & d).Value)
Audit.Sheets("Vehicles").Activate
Audit.Sheets("Vehicles").Unprotect
Audit.Sheets("Vehicles").AutoFilterMode = False
Audit.Sheets("Vehicles").Range("A1:A1").AutoFilter 2, ">" & 1, xlFilterValues
Audit.Sheets("Vehicles").Rows("1:1").Hidden = True
Audit.Sheets("Vehicles").Range("A1").CurrentRegion.Copy
WB.Range("A1000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Audit.Close False
d = d + 1

Loop

Thanks,
Dinesh
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
The code thinks there is something there.
see the result.

VBA Code:
msgbox cells(rows.count,"B").end(xlup).row
 
Upvote 0
Solution

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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