Error 75

Tjordaske

New Member
Joined
Nov 23, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
I'm creating a script that needs to create for each value in a list a new folder on the same location where the Excel with the list of values is saved.
It seems to work because my script is creating a folder for each value, but I get an error 75 each time I execute the script:

i = 1
a = Workbooks("Overzicht categorieën.xlsx").Sheets(1).Cells(i, 1).Value

Do While a <> ""
For Each cell In OutRng
dirname = Cells(i, 1).Value
MkDir (FilePath & "\" & dirname)
Next cell

i = i + 1
Loop


1639510264717.png


What goes wrong?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
It looks like it may be trying to create folders that already exist. I would try removing the Do loop since the for/next will do the looping through each cell.
 
Upvote 0
Hi @Candyman8019, don't I need a loop because when my script is only this:

For Each cell In OutRng
dirname = cell.Value
MkDir (FilePath & "\" & dirname)
Next cell


It's creating only a folder for the first value in the list, but not for the other values.
I don't have the error 75 now, but not the result I'm hoping for.
 
Upvote 0
move your I=I+1 before 'Next Cell so that it increments

For Each cell In OutRng
dirname = Cells(i, 1).Value
i = i + 1
MkDir (FilePath & "\" & dirname)
Next cell


I think you could also use the Do loop instead if you prefer.
Do While a <> ""
dirname = Cells(i, 1).Value
MkDir (FilePath & "\" & dirname)
i = i + 1
Loop
 
Upvote 0
Your first possibility is creating only a folder for the first value and it stops there. But no error.

Your second possibility is creating a folder for each value, but the error is back

1639512139283.png
 
Upvote 0
Here's what I had to do to get this working:

i = 1
a = Workbooks("Book1.xlsm").Sheets(1).Cells(i, 1).Value
filepath = "C:"
Do While a <> ""
dirname = Cells(i, 1).Value
MkDir (filepath & "\" & dirname)
i = i + 1
a = Workbooks("Book1.xlsm").Sheets(1).Cells(i, 1).Value
Loop

The filepath was the main thing that was missing. Then I added a line to update the 'a' variable after the value was incremented.
 
Upvote 0

Forum statistics

Threads
1,203,073
Messages
6,053,379
Members
444,660
Latest member
Mingalsbe

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