Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default automate importing

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default automate importing

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
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
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
automate importing text files? sinnetBS Excel Discussion (Misc queries) 0 June 22nd 06 11:34 PM
Automate without add-ins Rob Oldfield Excel Discussion (Misc queries) 3 October 21st 05 07:33 PM
Automate Add-in Gary's Student Excel Discussion (Misc queries) 4 June 20th 05 02:12 AM
Excel.......Automate importing multiple changing CSV's Devon[_2_] Excel Programming 1 August 28th 04 12:57 AM


All times are GMT +1. The time now is 03:21 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"