Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Loop through string of id's and perform task

Loop through string of id's and perform task


I am using Allen Browne code to concatenate records from
a table. This results in a string of id's.

For example "10,33,150,345" etc...

I would like to perform a task for each id, (I n this case
adding to a log table).

How would I go about looping through each id so I could
perform my vba code on each id?

Many thanks Mark.

RE: Loop through string of id's and perform task

Something like


    Dim sourcestring As String
    Dim taskdata As Variant
    sourcestring = "10,33,150,345"
    For Each taskdata In Split(sourcestring , ",")
        MsgBox Trim(taskdata) ' this is where you'd perform your task

RE: Loop through string of id's and perform task

Thank you very much.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close