Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write a set of instructions in VBA??

Status
Not open for further replies.

romij29

Technical User
Nov 23, 2004
49
GB
Hello
I have a GetOpen Filename program that works for two workbooks being copied into 2 sheets of a destination workbook.
However, i want a situation where I can say that if user chooses a file in a specific folder, then do a set of instructions,
However if the file chosen is in another specific folder do another set of instructions.
Basically it shd be like
If "file A obtained from GetOpenFilename is in a specific folder (defined by a variable)", then

copy and paste bla bla bla

ElseIf "file B chosen is in a specific folder (also def by variable)" then

Else MsgBox

End If

Problem is how do I write this in VBA speak?? quite new to this,,hahaha.
 
Well - you have it there

If <variable> = "a" then
'copy and paste code here
Else
'other code here
End If

or are you asking for help determining whcih folder the fle has come from ?? - that can be extracted from the Workbookname.FULLNAME or workbookname.PATH attribute

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top