Storing Variant into another program

mrtim2232

New Member
Joined
Aug 24, 2017
Messages
48
Hello All,

I have a program where I declare some variables e.g. a number for a header of a column this program then calls another program that opens other workbooks and runs some code in the workbook and needs to references the declared variable in the "main program" to add into each workbook without having to write it each time the code runs however it comes up blank any thoughts would be apprecaited.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
A version of the program I'm trying to run the "main_program" declares some variables using input boxes and then opens up a workbook to run the "numbers" program in each workbook in a folder based on the numbers input in the "main_program" but when it runs the numbers program it doesn't register the declared variables in the "main_program":

sub main_program()
Set masterwb = ActiveWorkbook
Dim lrow As Long
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
Dim FldrPicker As FileDialog
Application.ScreenUpdating = False
Application.EnableEvents = False
'Application.Calculation = xlCalculationManual
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & ""
End With
Dim myvalue As Variant
myvalue = InputBox("Please input the number to compare against, E.g. 4 ")
Dim myvalue_2 As Variant
myvalue_2 = InputBox("Please input the second number to compare against")
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
myExtension = "*.csv*"
myFile = Dir(myPath & myExtension)
Do While myFile <> ""
Set wb = Workbooks.Open(Filename:=myPath & myFile)
DoEvents
Application.Run ("'BOOK.xlsm'!numbers")
wb.SaveAs Filename:=myPath & Left(wb.Name, Len(wb.Name) - 4) & ".xlsx"
wb.Close
DoEvents
myFile = Dir
Loop

MsgBox "Task Complete!"
ResetSettings:
'Reset Macro Optimization Settings
Application.EnableEvents = True
'Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Upvote 0
That sounds right apologies I'm still getting to grips with learning the VBA code is there a possible solution?
 
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