I'm trying to merge the attached 2 excel files with below VBA code. It will copy all data from Summary011 but left out the last two lines from Summary002.
My guess is that because column A is blank for those two lines. How do I modify this VBA to include the last lines with blank in column A?
Many thanks.
We would very much like to help you with your query, however you need to include code tags around your code.
Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
I did it for you this time. Please read forum rules. Thanks
According to the attachment a beginner starter demonstration to paste to the destination worksheet module
then save the workbook to the csv source folder (or amend before saving the path variable in the next VBA code) :
PHP Code:
Sub Demo1() Dim P$, F$, N% P = ThisWorkbook.Path & Application.PathSeparator Me.UsedRange.Clear F = Dir(P & "*.csv") While F > "" With Me.QueryTables.Add("TEXT;" & P & F, Cells(Me.UsedRange.Rows.Count - Not IsEmpty([A1]), 1)) .AdjustColumnWidth = False .TextFileColumnDataTypes = [{1,1,4,1,1,1,1,1,1,1,4,1,1,1,1,1}] .TextFileCommaDelimiter = True .TextFileDecimalSeparator = "." .TextFileStartRow = 2 + (N = 0) .TextFileTextQualifier = xlTextQualifierNone .Refresh False: .Delete End With N = N + 1 F = Dir Wend MsgBox "# csv imported : " & N, vbInformation, " Import" End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » !
Bookmarks