Forum

Concatenating and D...
 
Notifications
Clear all

Concatenating and Do While Loop VBA

4 Posts
2 Users
0 Reactions
91 Views
(@shabbyexcel)
Posts: 3
Active Member
Topic starter
 

I have a Workbooks("Serial Number").Sheet1 where Column B contains data such as 0001, 0002 , 0003 , 0004 upto 9999 row wise and other Workbooks("Data").Sheet1 have data where ColA has such values 

 

205-371-

205-372-
205-373-
205-374- till used range

row wise

and i am looking to merge the data like below example on the Workbooks("Data").Sheet1 ColA.

205-371-0001
205-371-0002
205-371-0003
205-371-0004

The result will be as like picture.

 

Image

 

after that wants to add the loop in the formula section in below code.

m xFdItem As Variant

Dim xFileName As String

Application.ScreenUpdating = False

Application.DisplayAlerts = False

Set xFd = Application.FileDialog(msoFileDialogFolderPicker)

If xFd.Show = -1 Then

 xFdItem = xFd.SelectedItems(1) & Application.PathSeparator

 xFileName = Dir(xFdItem & "*.csv*")

End If

 

Wants to add here a concatenate formula with Do While Loop for all sheets a folder have. 

 

Dim Wkb As Workbook

With Application

.ScreenUpdating = False

For Each Wkb In Workbooks

With Wkb

If Not Wkb.ReadOnly Then

.Save

End If

If .Name <> ThisWorkbook.Name Then

.Close

End If

End With

Next Wkb

.ScreenUpdating = True

    End With

End Sub

 
Posted : 30/07/2020 2:13 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

This looks like a job for Power Query.  If you can provide some sample files with the source data then I can write a query for you.

regards

Phil

 
Posted : 30/07/2020 7:46 pm
(@shabbyexcel)
Posts: 3
Active Member
Topic starter
 

Sir i would like to request in this regards that please make this via VBA.

 
Posted : 31/07/2020 6:19 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

Why do more work than you need to?  If Power Query can do this then that's what I'd use. If PQ can't do it then we can look at a VBA solution.

Regards

Phil

 
Posted : 31/07/2020 8:55 am
Share: