Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 2
Default Help with VBA Macro needed

I created this Macro, but want to make a change but dont know how..
Hopefully someone can offer assitance.

Question1.
Instead of it looking for the file 1.csv, I want to look for all .CSV files on my desktop,
and allow me to choose the one to import


---------------------------------------------------------------------------------------------------
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 4/5/2012

' Keyboard Shortcut: Ctrl+d
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\my.computer\Desktop\1.csv", Destination _
:=Range("A1"))
.Name = "1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
------------------------------------------------------------------------------------------


Thankss..


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Help with VBA Macro needed

"Me" wrote:

I created this Macro, but want to make a change but dont know how..
Hopefully someone can offer assitance.

Question1.
Instead of it looking for the file 1.csv, I want to look for all .CSV
files on my desktop, and allow me to choose the one to import


Try this:

Sub allCSVsOnDesktop()
nextFile = Dir$("C:\users\Erik\Desktop\*.csv")
While Len(nextFile)
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\my.computer\Desktop\" & nextFile, _
Destination:=Range("A1"))
'everything you want to do with the table goes here
End With
nextFile = Dir$
Wend
End Sub

--
I'll see you tomorrow for our usual drink and argument.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Help with VBA Macro needed

I wrote:

nextFile = Dir$("C:\users\Erik\Desktop\*.csv")


Whoops... that should be:

nextFile = Dir$("C:\Documents and Settings\my.computer\Desktop\*.csv")

Forgot to change it from my "test" settings.

--
As he walked into the blinding golden light he turned, and looked
back over his shoulder. He smiled at me... I never saw him again.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Help with VBA Macro needed

As he walked into the blinding golden light he turned, and looked
back over his shoulder. He smiled at me... I never saw him again.


Keep stalking Auric.
I am sure you will see them again in the police station :)
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
macro needed please jackrobyn1 Excel Discussion (Misc queries) 3 June 6th 08 08:41 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to set macro security in Excel to minimum Carl Excel Programming 3 March 18th 06 03:36 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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