Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro Using VLookups


I am not sure if I am getting way ahead of myself for someone who just
started learning Excel VBA last week. But I have been trying to write a
Macro but have been very unsucessful with writing my most recent Macro.

Basically the Macro is to help me open up an external file and populate
information from the external file using a VLookup. This part works no
prob. But next week I have to write another Macro to do the same task as
I am not sure how to make my Macro Vlookup be generic so it can do the
lookup form only the file I specified.

Sub ProductionImport()
'
' ProductionImport Macro
' Macro recorded 10/14/2003 by Oshiz
'

'
myFile = Application.GetOpenFilename("Excel Files, *.xls")
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-28], '[Carlo Production
10-11-03.xls]Summary'!R12C1:R36C26, 3, FALSE)"
Range("AD11").Select
Selection.AutoFill Destination:=Range("AD11:AD29"),
Type:=xlFillDefault
Range("AD11:AD29").Select
End Sub

Next week I Will have a diff Production File. How do I get my macro to
bypass being stuck on pulling data from the 10-11-03 Production File?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Using VLookups

Sub ProductionImport()
'
' ProductionImport Macro
' Macro recorded 10/14/2003 by Oshiz
'

'
Dim sName as String
Dim sh as Worksheet
Dim myFile as String
set sh = Activesheet
myFile = Application.GetOpenFilename("Excel Files, *.xls")
workbooks.Open myfile
sName = Activeworkbook.Name
sh.parent.Activate
sh.Activate
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-28], '[" & sName & _
"]Summary'!R12C1:R36C26, 3, FALSE)"
Range("AD11").Select
Selection.AutoFill Destination:=Range("AD11:AD29"), _
Type:=xlFillDefault
Range("AD11:AD29").Select
End Sub


-- Regards,
Tom Ogilvy

"Oli Oshiz" wrote in message
...

I am not sure if I am getting way ahead of myself for someone who just
started learning Excel VBA last week. But I have been trying to write a
Macro but have been very unsucessful with writing my most recent Macro.

Basically the Macro is to help me open up an external file and populate
information from the external file using a VLookup. This part works no
prob. But next week I have to write another Macro to do the same task as
I am not sure how to make my Macro Vlookup be generic so it can do the
lookup form only the file I specified.

Sub ProductionImport()
'
' ProductionImport Macro
' Macro recorded 10/14/2003 by Oshiz
'

'
myFile = Application.GetOpenFilename("Excel Files, *.xls")
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-28], '[Carlo Production
10-11-03.xls]Summary'!R12C1:R36C26, 3, FALSE)"
Range("AD11").Select
Selection.AutoFill Destination:=Range("AD11:AD29"),
Type:=xlFillDefault
Range("AD11:AD29").Select
End Sub

Next week I Will have a diff Production File. How do I get my macro to
bypass being stuck on pulling data from the 10-11-03 Production File?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't I sum several vlookups ?? Friday Excel Worksheet Functions 5 November 6th 09 06:42 PM
IFs with VLOOKUPs Brad Autry Excel Worksheet Functions 5 August 4th 09 03:02 PM
vlookups hcronrath Excel Worksheet Functions 1 February 11th 09 07:41 PM
Dependent vlookups - nested vlookups (maybe) Maniv Excel Worksheet Functions 1 April 22nd 08 07:40 PM
Macro - Insert column with VLookups Chris Excel Discussion (Misc queries) 0 March 14th 08 11:15 AM


All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"