Runtime 1004 error

HERMONES

Board Regular
Joined
Jan 24, 2014
Messages
166
I have this code below which is causing a runtime error on the first row.
I have set the getfilesfrom and filenameimport as variables.
Im not sure why its happening, it opens the files fine, but then refers to a column in the spreadsheet saying it cannot find it, but the VBA does not tell it to find it?

Workbooks.Open FileName:=GetFilesFrom & FilenameImport (ERROR)
Workbooks.Open FileName:=TemplateFolder & TemplateName
Windows(FilenameImport).Activate
Worksheets.Item(3).Activate
Range("A1").Select
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = "" Then
Application.Run ("BuildContacts")

End If


Confused!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks for your response. Yes thats correct.

Dim EmployeeId As String
Dim TemplateName As String
Dim GetFilesFrom As String
Dim TemplateFolder As String
Dim BuildLocation As String
Dim SaveBuiltDBFilename As String
Dim FilenameImport As String
Dim ThisFilename As String
Dim LastRow As Long
Dim FirstRow As Long
Dim MsgDone As String

FilenameImport = Range("C4").Value
TemplateName = Range("C5").Value
TemplateFolder = Range("C6").Value
BuildLocation = Range("C7").Value
ThisFilename = Range("C8").Value
GetFilesFrom = Range("C9").Value
SaveBuiltDBFilename = Range("C10").Value
 
Upvote 0
Yes, but what do those variables actually contain when you get the error? Maybe you are missing a path separator at the end of the folder.
 
Upvote 0

Forum statistics

Threads
1,224,900
Messages
6,181,632
Members
453,059
Latest member
jkevin

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