Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can i automate importing of worksheets from cvs files into an open work
book? I was thinking of creating a button to contain a macro that would have a pop up window that let the user choose the file to import, and have the macro delete the old tab and rename the imported tab what ever i hard code it to be. I could really use some help on this whole thing I know what i want but dont know how to get there. -- Message posted via http://www.officekb.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd start by recording a macro when I did it manually.
The post back if you need help tweaking the code. "jln via OfficeKB.com" wrote: How can i automate importing of worksheets from cvs files into an open work book? I was thinking of creating a button to contain a macro that would have a pop up window that let the user choose the file to import, and have the macro delete the old tab and rename the imported tab what ever i hard code it to be. I could really use some help on this whole thing I know what i want but dont know how to get there. -- Message posted via http://www.officekb.com -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey david thanks for the post.
Dave Peterson wrote: I'd start by recording a macro when I did it manually. The post back if you need help tweaking the code. How can i automate importing of worksheets from cvs files into an open work book? I was thinking of creating a button to contain a macro that would have [quoted text clipped - 5 lines] -- Message posted via http://www.officekb.com -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A record macro will not help me in this case becuase the file name changes
for each person thats why i want to use GetOpenFilename. Im just not sure how. Dave Peterson wrote: I'd start by recording a macro when I did it manually. The post back if you need help tweaking the code. How can i automate importing of worksheets from cvs files into an open work book? I was thinking of creating a button to contain a macro that would have [quoted text clipped - 5 lines] -- Message posted via http://www.officekb.com -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Recording the macro will get a lot of the code.
Then you can start tweaking it... Option Explicit Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="CSV Files, *.CSV", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.Open Filename:=myFileName '....rest of recorded code here! End Sub "jln via OfficeKB.com" wrote: A record macro will not help me in this case becuase the file name changes for each person thats why i want to use GetOpenFilename. Im just not sure how. Dave Peterson wrote: I'd start by recording a macro when I did it manually. The post back if you need help tweaking the code. How can i automate importing of worksheets from cvs files into an open work book? I was thinking of creating a button to contain a macro that would have [quoted text clipped - 5 lines] -- Message posted via http://www.officekb.com -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok that gave me a good start i have it opening the file then coping. My next
step would be how do i make it activate the right workbook. The work book names are always different. Dave Peterson wrote: Recording the macro will get a lot of the code. Then you can start tweaking it... Option Explicit Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="CSV Files, *.CSV", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.Open Filename:=myFileName '....rest of recorded code here! End Sub A record macro will not help me in this case becuase the file name changes for each person thats why i want to use GetOpenFilename. Im just not sure how. [quoted text clipped - 12 lines] Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The .csv file that you just opened will be the activeworkbook. But you could
use a variable to represent that workbook, too: Option Explicit Sub Testme01() Dim myFileName As Variant Dim myWkbk as workbook myFileName = Application.GetOpenFilename(filefilter:="CSV Files, *.CSV", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If set mywkbk = Workbooks.Open(Filename:=myFileName) '....rest of recorded code here! End Sub Then you can refer to that CSV workbook file with: mywkbk.worksheets(1).range("a1").value = "whatever you wanted" "jln via OfficeKB.com" wrote: Ok that gave me a good start i have it opening the file then coping. My next step would be how do i make it activate the right workbook. The work book names are always different. Dave Peterson wrote: Recording the macro will get a lot of the code. Then you can start tweaking it... Option Explicit Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="CSV Files, *.CSV", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.Open Filename:=myFileName '....rest of recorded code here! End Sub A record macro will not help me in this case becuase the file name changes for each person thats why i want to use GetOpenFilename. Im just not sure how. [quoted text clipped - 12 lines] Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200611/1 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Importing Alan Beban's code on Arrays; Importing a module or a project | Excel Worksheet Functions | |||
automate importing text files? | Excel Discussion (Misc queries) | |||
Automate without add-ins | Excel Discussion (Misc queries) | |||
Automate Add-in | Excel Discussion (Misc queries) | |||
Excel.......Automate importing multiple changing CSV's | Excel Programming |