• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • SALE 20% Off All Courses
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Concatenating and Do While Loop VBA|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Concatenating and Do While Loop VBA|VBA & Macros|Excel Forum|My Online Training Hub
                    BLACK FRIDAY SALE 20% OFF ALL COURSES
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosConcatenating and Do While Loop VBA
sp_PrintTopic sp_TopicIcon
Concatenating and Do While Loop VBA
Avatar
Shabby Ali

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
July 30, 2020
sp_UserOfflineSmall Offline
1
July 30, 2020 - 4:13 am
sp_Permalink sp_Print

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.

 

ImageImage Enlarger

 

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

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1563
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
July 30, 2020 - 9:46 am
sp_Permalink sp_Print

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

Avatar
Shabby Ali

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
July 30, 2020
sp_UserOfflineSmall Offline
3
July 30, 2020 - 8:19 pm
sp_Permalink sp_Print

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

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1563
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
July 30, 2020 - 10:55 pm
sp_Permalink sp_Print

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

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Timothy, Velouria, Sean O'Hagan, Jill Niemeier, Bright Asamoah, Pam Baillie, Todd Heckman
Guest(s) 7
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Catalin Bombea: 1864
SunnyKow: 1432
Anders Sehlstedt: 886
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 241
Hans Hallebeek: 227
Jessica Stewart: 219
A.Maurizio: 213
Newest Members:
Kelvin H
Anya Ledwith
Mark Melvin
Stuart McInnes
Naji Moukhachen
Robert Mason
Debora Cohen
Kris Whitaker
Rajesh Jawajala
Todd Heckman
Forum Stats:
Groups: 3
Forums: 24
Topics: 6641
Posts: 29140

 

Member Stats:
Guest Posters: 49
Members: 33096
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.