NCSUVBAnewb
Technical User
Hey all,
I've got a VBA module that runs a userform that prompts for a certain set of data, finds and opens a file based on the user input, inputs and formats that data, and saves to a new directory. I'm having difficulties passing the data as variables from the UserForm I created back to the module to be inserted into the file path that needs to be opened. Code below:
Module:
...the remaining code is just formatting stuff which is irrelevant.
NOTE: The commented out stuff above is how I would like the file path to ultimately look, but it isn't importing the variables as needed.
UserForm:
Basically I think the problem lies somewhere in the variable declaration (as public/private/etc) or the storing of the variable in the userform.
Any ideas?
I've got a VBA module that runs a userform that prompts for a certain set of data, finds and opens a file based on the user input, inputs and formats that data, and saves to a new directory. I'm having difficulties passing the data as variables from the UserForm I created back to the module to be inserted into the file path that needs to be opened. Code below:
Module:
Code:
Option Explicit
Dim MonthDay As String
Dim InsString As String
Dim CalDate As String
Sub InputDate()
FindInput.Show
Call ImportData
End Sub
Sub ImportData()
Workbooks.OpenText Filename:="D:\3DMGT\08ALLTXTS\0801\" & InsString & "080104.TXT", Origin:=437, StartRow:=1, DataType:=xlFixedWidth
'Workbooks.OpenText Filename:="D:\3DMGT\08ALLTXTS\" & MonthDay & "\" & InsString _
'& "_" & MonthDay & CalDate & ".TXT", Origin:=437, StartRow:=1, DataType:=xlFixedWidth
Call FormatImported
End Sub
Sub FormatImported()
NOTE: The commented out stuff above is how I would like the file path to ultimately look, but it isn't importing the variables as needed.
UserForm:
Code:
Private Sub cmdCancel_Click()
Unload Me
End Sub
Public Sub cmdOK_Click()
YYMM.Value = MonthDay
cboCoord.Value = InsString
cboDay.Value = CalDate
Exit Sub
End Sub
Private Sub UserForm_Initialize()
YYMM.Value = ""
With cboCoord
.AddItem "16-41"
.AddItem "24-09"
.AddItem "24-41"
.AddItem "32-17"
.AddItem "32-25"
.AddItem "40-25"
End With
cboCoord.Value = ""
With cboDay
.AddItem "01"
.AddItem "02"
.AddItem "03"
.AddItem "04"
.AddItem "05"
.AddItem "06"
.AddItem "07"
.AddItem "08"
.AddItem "09"
.AddItem "10"
.AddItem "11"
.AddItem "12"
.AddItem "13"
.AddItem "14"
.AddItem "15"
.AddItem "16"
.AddItem "17"
.AddItem "18"
.AddItem "19"
.AddItem "20"
.AddItem "21"
.AddItem "22"
.AddItem "23"
.AddItem "24"
.AddItem "25"
.AddItem "26"
.AddItem "27"
.AddItem "28"
.AddItem "29"
.AddItem "30"
.AddItem "31"
End With
cboDay.Value = ""
YYMM.SetFocus
End Sub
Basically I think the problem lies somewhere in the variable declaration (as public/private/etc) or the storing of the variable in the userform.
Any ideas?