Import and update several CSV files automatically into Excel workbook by the click of a button

szeconku

New Member
Joined
Jul 31, 2015
Messages
2
I have a folder containing multiple CSV files and I have another folder containing an Excel workbook. I want to import all the CSV files from the workbook by the click of a button into seperate sheets (fx 3.csv will have sheetname "3" etc.) without having to specify which one to open. These CSV files are updated frequently, however not always on the same day. I want the import code to also update/overwrite whatever CSV files have been updated. I assume that this is implicitly done every time I import all the files.

The following code does the trick..well almost. The problem is whenever I click on the button it doesn't overwrite the existing sheets. It adds new sheets. Let's say I upload (for the very first time). The sheets inside the workbook are called city1.csv, city2.csv etc.. The second time I run the code, it has added another range of sheets city1, city2 etc. The third time city1(1), city2(2) etc.

How can I make the import code to overwrite every time I click on the button instead of adding new sheets once the first sheets have been added?

Sub import_test3()
Dim MyPath As String
Dim FilesInPath As String
Dim MyFiles() As String
Dim SourceRcount As Long
Dim Fnum As Long
Dim mybook As Workbook
Dim basebook As Workbook

MyPath = "\\filepath\folder"

If Right(MyPath, 1) <> "\" Then
MyPath = MyPath & "\"
End If

FilesInPath = Dir(MyPath & "*.csv")
If FilesInPath = "" Then
MsgBox "No CSV files found"
Exit Sub
End If

On Error GoTo CleanUp

Application.ScreenUpdating = False
Set basebook = ThisWorkbook

Fnum = 0
Do While FilesInPath <> ""
Fnum = Fnum + 1
ReDim Preserve MyFiles(1 To Fnum)
MyFiles(Fnum) = FilesInPath
FilesInPath = Dir()
Loop

If Fnum > 0 Then
For Fnum = LBound(MyFiles) To UBound(MyFiles)
Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))
mybook.Worksheets(1).Copy after:= _
basebook.Sheets(basebook.Sheets.Count)

On Error Resume Next
ActiveSheet.Name = mybook.Name
On Error GoTo 0


mybook.Close savechanges:=False
Next Fnum
End If
CleanUp:
Application.ScreenUpdating = True
End Sub

I assume the problem is in the "mybook.Worksheets(1).Copy after:="-part. Don't know how to let the workbook recognize existing sheets (while also being able to import the CSV files the first time). Please help.

Thx!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
You need an if clause to test whether the target tab already exists. If it does, overwrite, otherwise create new.

One option would be to delete all the existing tabs at the start of the import process, then the new ones would arrive. Or import all, then delete any where two exist and rename accordingly - a bit messier but you can audit which ones changed.
 
Upvote 0
If the data exceeds 65500 rows. I need to import the data to <gs id="9518274d-8034-47de-94e2-d745df60cc31" ginger_software_uiphraseguid="33041d68-2944-4618-9f4d-f7746b01cac0" class="GINGER_SOFTWARE_mark">next sheet</gs>. Please change this code

Sub Import_Click<gs id="a00b5fa6-82b5-4d2d-b331-c2180529e63a" ginger_software_uiphraseguid="4ecac250-1d4b-437b-bbec-9704c00fda4e" class="GINGER_SOFTWARE_mark">(</gs>)
Dim sPath As String
Dim <gs id="feff906f-1631-4313-93dd-c7aa4bf471e4" ginger_software_uiphraseguid="1a55c21d-f9df-4613-9045-4764c58c8dc9" class="GINGER_SOFTWARE_mark">oPath</gs>, <gs id="550cc7fb-77fa-4015-a458-638fd11e1524" ginger_software_uiphraseguid="1a55c21d-f9df-4613-9045-4764c58c8dc9" class="GINGER_SOFTWARE_mark">oFile</gs>, FSO As Object
Dim r, <gs id="cad373f4-e7d3-48df-adba-ce9f8082974b" ginger_software_uiphraseguid="02c4da27-b190-4ae0-953f-265e9bdc8698" class="GINGER_SOFTWARE_mark">iRow</gs>, <gs id="50b85ffc-c9fa-4476-83f4-7c4c2493f1cd" ginger_software_uiphraseguid="02c4da27-b190-4ae0-953f-265e9bdc8698" class="GINGER_SOFTWARE_mark">iSheet</gs> As Long
Dim <gs id="fd1236c1-74de-420d-b674-24d794ecd47d" ginger_software_uiphraseguid="93c363ad-dd37-43f4-990e-a2187f954eb9" class="GINGER_SOFTWARE_mark">wbImportFile</gs> As Workbook
Dim <gs id="ad5a57dc-b768-4700-949d-de23e2c5a143" ginger_software_uiphraseguid="5f123f90-56a1-451c-914c-39318de30220" class="GINGER_SOFTWARE_mark">wsDestination</gs> As Worksheet


'Files location
<gs id="d63a1578-eb91-414b-879c-25b2e347e4ba" ginger_software_uiphraseguid="e67d0b3b-27f0-40bf-a988-b8209ade89a9" class="GINGER_SOFTWARE_mark">sPath</gs> = "D:\CTL\"
'<gs id="4327576e-da44-47fb-b1a2-48ece8645dc4" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">sPath</gs> = Application<gs id="0276febe-0cc2-4952-9448-9aaff1327498" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">.</gs>GetOpenFilename<gs id="a1d56fdc-17d3-4160-99e4-432ff97bc28a" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">(</gs>"TXT Files (*<gs id="3ddd1890-fdbe-403f-a76a-83933d6db22d" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">.</gs><gs id="ffb0f18f-705e-43dd-8878-d6f7f7d151c1" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">ctl</gs>), *<gs id="0963923e-8785-4a6f-8351-75fade49855c" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">.</gs><gs id="8bb00d35-a822-4bcf-90f3-667d7c3b4718" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">ctl</gs>", 1, "Select a file"<gs id="de7fa5d2-a483-4c76-8e3d-63df19edb7be" ginger_software_uiphraseguid="7ed45645-fb6a-41b0-ae4b-74fc1ce8f5bf" class="GINGER_SOFTWARE_mark">, ,</gs> False)
Set <gs id="cadc4463-e43f-4876-a5c3-3582a6b5bd40" ginger_software_uiphraseguid="5306022f-2181-4c68-904e-6ff9b4c71c6a" class="GINGER_SOFTWARE_mark">wsDestination</gs> = ThisWorkbook<gs id="ad1d6d2d-86c9-409e-b5b1-fbe8ca57c91b" ginger_software_uiphraseguid="5306022f-2181-4c68-904e-6ff9b4c71c6a" class="GINGER_SOFTWARE_mark">.</gs>Sheets<gs id="6e44488b-f784-491b-a2a5-38764aeb5a4e" ginger_software_uiphraseguid="5306022f-2181-4c68-904e-6ff9b4c71c6a" class="GINGER_SOFTWARE_mark">(</gs>"Sheet2")


<gs id="c153f265-b243-42bc-8448-84105b8efd67" ginger_software_uiphraseguid="db449088-c54d-4150-972e-f0246e6dc8fb" class="GINGER_SOFTWARE_mark">r</gs> = 1
<gs id="4f4cf58f-81e8-45cb-8117-f54bbd1520ba" ginger_software_uiphraseguid="8ea3f922-4066-4b48-b04a-d2f059d2a8ea" class="GINGER_SOFTWARE_mark">iSheet</gs> = 2
Set FSO = CreateObject<gs id="64ae198c-85ad-4dba-af59-89eefd5981fc" ginger_software_uiphraseguid="17e2982c-8061-4b09-a528-f8aec4f0e1e1" class="GINGER_SOFTWARE_mark">(</gs>"Scripting<gs id="66f1f0d4-a6b3-4b5f-aed2-4d8696c01189" ginger_software_uiphraseguid="17e2982c-8061-4b09-a528-f8aec4f0e1e1" class="GINGER_SOFTWARE_mark">.</gs>FileSystemObject")
Set <gs id="c016b4b4-d86c-4c38-a72c-f2a7aa5a980a" ginger_software_uiphraseguid="1d0cce53-b410-4c8d-8d3b-b94db0c64ba0" class="GINGER_SOFTWARE_mark">oPath</gs> = FSO<gs id="c717516f-e6dd-4dec-aa5c-d7f6dfad2940" ginger_software_uiphraseguid="1d0cce53-b410-4c8d-8d3b-b94db0c64ba0" class="GINGER_SOFTWARE_mark">.</gs>GetFolder<gs id="0ca3f192-9871-46aa-b51a-1d03f4819397" ginger_software_uiphraseguid="1d0cce53-b410-4c8d-8d3b-b94db0c64ba0" class="GINGER_SOFTWARE_mark">(</gs><gs id="60c49009-22b1-4613-8e54-7d511b9aa2a2" ginger_software_uiphraseguid="1d0cce53-b410-4c8d-8d3b-b94db0c64ba0" class="GINGER_SOFTWARE_mark">sPath</gs>)
Application<gs id="474bb74e-96ab-4912-baf1-befd785c2ba3" ginger_software_uiphraseguid="b8b0990b-ab56-452e-b2eb-32771d80759a" class="GINGER_SOFTWARE_mark">.</gs>ScreenUpdating = False
For Each oFile In <gs id="df2ed821-66b6-427e-8486-9ba2d8530a50" ginger_software_uiphraseguid="566662ff-a766-4ed3-a175-b79e8032bd93" class="GINGER_SOFTWARE_mark">oPath</gs><gs id="9198044f-f0aa-4134-8ec9-4be134e8b20b" ginger_software_uiphraseguid="566662ff-a766-4ed3-a175-b79e8032bd93" class="GINGER_SOFTWARE_mark">.</gs>Files
If LCase<gs id="b92d1b36-b169-4210-aafd-ffcdddce4d2d" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">(</gs>Right<gs id="c638a851-ee20-4478-b9e1-b45b7b34ef33" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">(</gs><gs id="a8904642-e2cb-4258-aee2-1cc0e8830725" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">oFile</gs><gs id="c1c5494c-22a4-4f3f-937c-74eba9aacd24" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">.</gs>Name, 4)) = "<gs id="6b350ccb-71e8-47ac-9924-f5da2dea1db5" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">.</gs><gs id="1c8ca41b-14bd-4978-9fb6-ae00d1d6dae1" ginger_software_uiphraseguid="c686cc64-f012-44be-bbe5-180282d52145" class="GINGER_SOFTWARE_mark">ctl</gs>" Then
'<gs id="56b9e43c-f79e-4af6-9b0e-25f234e6956d" ginger_software_uiphraseguid="b7fe8cc1-a432-4658-95c2-bbe76c577329" class="GINGER_SOFTWARE_mark">open</gs> file to <gs id="6d0cd0e0-803f-4725-8ed8-b1adb8ad2f20" ginger_software_uiphraseguid="b7fe8cc1-a432-4658-95c2-bbe76c577329" class="GINGER_SOFTWARE_mark">impor</gs>
Workbooks<gs id="f5e8459a-7e7a-4f13-8ca4-aa5a4be216ec" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">.</gs>OpenText Filename<gs id="f6efc5c8-1526-4b4e-9dfb-7621c51deee3" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">:</gs>=oFile<gs id="3373efee-ed2d-442b-9582-b553ce732850" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">.</gs>Path, Origin<gs id="6ae435f5-ec8f-4d3b-a8f7-ff0432b200bd" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">:</gs>=65001, StartRow<gs id="78e07648-990b-4da1-b275-c9835e7ca568" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">:</gs>=1, <gs id="e275a9a4-eee3-4fb0-9a38-6ba8e5545a97" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">DataType</gs><gs id="d6d122fc-610f-40f9-bab8-d7ea8c22a01f" ginger_software_uiphraseguid="060346c2-b78e-4b96-881e-855d4f40706a" class="GINGER_SOFTWARE_mark">:</gs>=xlDelimited, _
<gs id="73f9a688-061e-4f4d-bb44-b7f7434668bc" ginger_software_uiphraseguid="332fab4a-106c-49b7-907b-6f9364c239c8" class="GINGER_SOFTWARE_mark">TextQualifier</gs><gs id="a66f1998-4b43-4d76-be6b-464ee2ca5408" ginger_software_uiphraseguid="332fab4a-106c-49b7-907b-6f9364c239c8" class="GINGER_SOFTWARE_mark">:</gs>=xlDoubleQuote, ConsecutiveDelimiter<gs id="abf3674f-a733-4f91-998a-439398090c9f" ginger_software_uiphraseguid="332fab4a-106c-49b7-907b-6f9364c239c8" class="GINGER_SOFTWARE_mark">:</gs>=False, Other<gs id="d56747c2-7723-4faa-a461-6c0b5c21cb0e" ginger_software_uiphraseguid="332fab4a-106c-49b7-907b-6f9364c239c8" class="GINGER_SOFTWARE_mark">:</gs>=True _
, <gs id="e36bde70-9df4-4d28-bfa6-1b7f2f059662" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">OtherChar</gs><gs id="ef946374-e8bf-47f4-aeac-04421ea96855" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">:</gs>="|", FieldInfo<gs id="0086a8af-ee64-4c82-9e4c-f732cf3ee46c" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">:</gs>=Array<gs id="7d10b745-1129-4a86-8c63-e64e13569dce" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">(</gs>Array<gs id="57b2fce7-a688-4e0b-a001-7c84d5e29559" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">(</gs>1, <gs id="2c335c96-5006-411a-bf16-21dd83e2190f" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="3fcf1882-5688-4667-8097-db4891edc137" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">(</gs>2, <gs id="7f2aa87e-c655-48ab-9395-ba03d4c75243" ginger_software_uiphraseguid="92e77582-61fd-46eb-bf81-867ca8a6f2d2" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), _
Array<gs id="f589f013-632e-46fe-aeac-682c6f363b13" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>3, <gs id="ffb72f99-fcbd-47e0-bd99-13655668be4a" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="4303ec91-1f41-4495-a0ac-b4e0a88ea755" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>4, <gs id="89387918-00b3-466a-b17c-3037e729e293" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="fb2ed556-b496-4dc2-b525-9f102641af1a" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>5, <gs id="f8be5a33-00f1-484c-8128-7e35b8521221" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="bdb00c8e-49f2-4208-b2e9-5600585ae7eb" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>6, <gs id="83b37d64-fe24-42f2-afe2-4d1333f5dac0" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="225618e6-dd81-47eb-9cc9-13c55d15085a" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>7, <gs id="1f29ff27-f5c7-416e-9c65-c1bfb6303ff9" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="2d6cf6dd-3f9f-4e05-be9d-c65924e3fcb3" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>8, <gs id="2e35a08d-1e00-4ee9-98ff-0972ab320ae5" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="1aa15c29-8f60-4e5a-87c3-26554930da99" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>9, <gs id="7028d9da-4f05-46d4-b9d8-5f6627264d74" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="433a5b38-2183-451b-8588-798af9458c92" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>10, <gs id="0d149790-d04d-4917-a2b7-0b5261da4dd9" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>), Array<gs id="9b9f5ab7-370f-4f17-acec-d4649ad59198" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">(</gs>11, <gs id="2e1fe806-8cc2-4979-a4e6-2e1f3e13a431" ginger_software_uiphraseguid="b7811a1f-31b6-44cf-bc0f-ee337f589766" class="GINGER_SOFTWARE_mark">xlTextFormat</gs>)), _
<gs id="23e88224-f02c-43f6-a427-0a9dc8b98916" ginger_software_uiphraseguid="6467f8e6-37bc-4703-8dcf-1c53457c25dc" class="GINGER_SOFTWARE_mark">TrailingMinusNumbers</gs><gs id="61c424a9-f862-4a3c-bd07-8dfbe317c216" ginger_software_uiphraseguid="6467f8e6-37bc-4703-8dcf-1c53457c25dc" class="GINGER_SOFTWARE_mark">:</gs>=True
Set <gs id="f29e2d9b-aa05-4aff-a216-54dcf58ed576" ginger_software_uiphraseguid="f8ecea3e-23fc-497b-8ab4-71cf1bc704af" class="GINGER_SOFTWARE_mark">wbImportFile</gs> = ActiveWorkbook
For <gs id="765e147b-df84-43b2-be35-d1467cd7cf60" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">iRow</gs> = 1 To <gs id="14c23e21-cc22-408f-abd2-9ae39274cd4f" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">wbImportFile</gs><gs id="ecf67e1e-ad26-4014-9665-d6c18f189b90" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">.</gs>Sheets<gs id="87629a0a-e7ce-41cd-89ee-9107fd76d1f1" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">(</gs>1)<gs id="9fa9613e-e27f-43d3-8245-ecb9ff12df8c" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">.</gs>UsedRange<gs id="64b9b0fd-1342-4650-9154-ac67f10b741d" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">.</gs>Rows<gs id="dd0eb810-2aa5-4b65-8559-cb550063fd1a" ginger_software_uiphraseguid="67e0e027-1da0-49cc-8a45-085d126e3a27" class="GINGER_SOFTWARE_mark">.</gs>Count
<gs id="8c29fd8a-3c24-4d8c-a803-4c86a3ce51a8" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">wbImportFile</gs><gs id="2b3ee335-08d9-4263-9944-4d006aabd0d2" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">.</gs>Sheets<gs id="913d7a25-9b3e-4da4-bb04-c694b78dcd0f" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">(</gs>1)<gs id="c22e96c4-4f6a-4557-b975-49a128f96d93" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">.</gs>Rows<gs id="35917571-1235-451d-a190-52a751813f24" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">(</gs><gs id="50416b1e-7d6d-4ce9-8c58-c0d6a0d8352a" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">iRow</gs>)<gs id="a1063238-bc4d-41c5-845e-4be89656ee28" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">.</gs>Copy <gs id="4991558e-6cf7-477c-b4b1-616cb58219d1" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">wsDestination</gs><gs id="e7d283b4-3390-4bf1-a1c3-140455c0ab31" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">.</gs>Rows<gs id="b26a1644-8388-4df4-bc75-ce84d93c8166" ginger_software_uiphraseguid="068fb612-1cc6-491d-b0ae-dc4cac02f572" class="GINGER_SOFTWARE_mark">(</gs>r)
<gs id="c3f88bfb-496a-4bc8-a9b2-b6d4e373e2df" ginger_software_uiphraseguid="b70821c3-74bf-4877-b7d0-e5a3a4b10809" class="GINGER_SOFTWARE_mark">r</gs> = r + 1
Next <gs id="f43f3be7-ae82-4c51-b8dd-5ffc0dbb223c" ginger_software_uiphraseguid="babeb595-7687-4019-bff1-c43a82e0b758" class="GINGER_SOFTWARE_mark">iRow</gs>
<gs id="13004bca-62fd-4c25-99a7-3c114ebb641a" ginger_software_uiphraseguid="cc059cae-675a-4433-bd44-7e0a24aa6353" class="GINGER_SOFTWARE_mark">wbImportFile</gs><gs id="a1610b5d-355f-40e0-bfec-e27651fa6303" ginger_software_uiphraseguid="cc059cae-675a-4433-bd44-7e0a24aa6353" class="GINGER_SOFTWARE_mark">.</gs>Close False
Set <gs id="a99f287c-5dd3-432f-b418-96f975d172ec" ginger_software_uiphraseguid="8329509e-a6a4-4a2c-bf1f-d07147bafeaf" class="GINGER_SOFTWARE_mark">wbImportFile</gs> = Nothing
End If
Next <gs id="cc0dddc4-dbbd-459e-9389-1bd7210d2bd3" ginger_software_uiphraseguid="30e4a04b-ce8a-47bb-8faf-aa0782eba809" class="GINGER_SOFTWARE_mark">oFile</gs>
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top