VBA code for excel form

phillip87

Board Regular
Joined
Jan 28, 2019
Messages
69
I have made a data form which I would like to always show on "sheet1" and add new lines of data to "sheet2" horizontally so I can then work with the data without having people mess with it however I keep getting debug errors.

I have tried looking online however everything i find is too complicated and i am too new to VBA to debug them.

can someone help me out with the VBA code on this, new to the VBA so will not bother attaching what I have, just need something simple to work the below.

my form has the following.

date (text box)
department (combo box)
file numbers(text box)
box numbers(text box)
add(command box)
new(command box)

Thanks.​
 
Last edited:
Re: help with a simple VBA code for excel form

FolderName = "P:\Penrose work\KPI Data\Dashboard Data and reports"

it works if the data WB is open but if only the dashboard is open then it cannot find it.

it says cannot find in "P:\Penrose work\KPI Data\Dashboard Data and reports\Dashboard Data and reports"

That suggests that you have not entered the FolderName correctly.

Open a blank workbook & turn macro recorder on and then Open the file on your network

Once open, turn macro recorder off & then inspect the code created.

Compare the The FilePath & FileName parts with what you are entering & see if any differences.

Dave
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Re: help with a simple VBA code for excel form

Sub WBfolder()
'
' WBfolder Macro
' open Wb from folder
'


'
Workbooks.Open Filename:= _
"P:\Penrose work\KPI Data\Dashboard Data and reports.xlsx", UpdateLinks:=0
End Sub
 
Upvote 0
Re: help with a simple VBA code for excel form

Sub WBfolder()
'
' WBfolder Macro
' open Wb from folder
'


'
Workbooks.Open Filename:= _
"P:\Penrose work\KPI Data\Dashboard Data and reports.xlsx", UpdateLinks:=0
End Sub


There is your answer


You entered

Code:
FolderName = "P:\Penrose work\KPI Data\Dashboard Data and reports"

but you need

Code:
FolderName = "P:\Penrose work\KPI Data"

Dave
 
Upvote 0
Re: help with a simple VBA code for excel form

ah OK I get it now, i was saying the folder had the same name as the WB.

thank you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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