Stiil struggling with userforms

rhino4eva

Active Member
Joined
Apr 1, 2009
Messages
262
Office Version
  1. 2010
Platform
  1. Windows
Sub SaveEngine(sFileNum As String)

StrDate = Format(Now(), "dd-mmm-yyyy")
RunNum = Sheets("Sheet1").Range("e3").Value

Sheets("ABI-" & sFileNum).SaveAs Filename:=FileLoc & "\RESP ABI\ABI-Resp " & sFileNum & " " & StrDate & " " & RunNum & ".txt", FileFormat:=xlTextMSDOS, CreateBackup:=False
MsgBox "File saved as : " & FileLoc & "\RESP ABI\ABI-Resp " & sFileNum & " " & StrDate & " " & RunNum & ".txt"

Err.Clear

End Sub
------------------------------------------------------------------------------------------------
Sub NETWORK()
If Sheets("DATA").Range("D1").Value < 22 Then
Call SaveEngine("1PLATE")
End If
If Sheets("DATA").Range("D1").Value > 21 Then
Call SaveEngine("Flu&Sw")
Call SaveEngine("RSV&PF")
End If
End Sub
-----------------------------------------------------------------------------------------------------
!userform!

Option Explicit
Dim FileLoc As String
--------------------------------------
Private Sub CommandButton1_Click()

FileLoc = "F:"
Call NETWORK
End Sub
---------------------------------------
Private Sub CommandButton2_Click()

FileLoc = "Z:"
Call NETWORK
End Sub
---------------------------------------


as you can see i have 3 bits of code i am tying to staple together.
1) is the save engine so i can do the same task once or twice dependant the number of entries on DATA
2) is the fuel area for the engine that decides file filenames and sheet names to use
3) although this is the last bit it actually is a user based decision userform that pick which device to save to

no matter how i try i cant the FileLoc variable form the userform to work in the SaveEngine area of the code
i know i must me missing something ...but what !!!!!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Remove this from the userform module
Code:
Dim FileLoc As String
and then put this
Code:
Public FileLoc As String
at the top of a regular module
 
Upvote 0
Should work, you did put it in a regular module (eg Module1) rather than a sheet module, or the ThisWorkbook module?
 
Upvote 0
I did do it as instructed . The problem was further down the code so you were right but I hadn't fully debugged it .... thanks
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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