1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Trying to loop a macro

Discussion in 'Business Applications' started by MissHeck73, Jan 8, 2019.

  1. MissHeck73

    MissHeck73 Thread Starter

    Joined:
    Jan 8, 2019
    Messages:
    1
    Hi there.
    I am taking 6 digit numbers from an excel sheet, pasting them into word and making some changes to allow me to put them into another system where I can verify some details. Some times I only need to transfer a few numbers, other times I need to transfer up to 1000.

    So the data transfer across from Excel to word in the following format

    123456
    457812
    798811
    .......and so on

    To put it into the last system I need it to be in the following format, which I do in word:

    '123456', '457812', ' 798811',......... and so on

    So I can create a macro, example below:

    Selection.TypeText Text:=" ' "
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" ' "
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', ' "
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" ', "

    How can I loop this to end when the numbers run out? As the data that i need to transfer varies everytime is there an easy way to do this.

    Thanking you in advance for your assistance.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Trying loop macro
  1. 4dsmom
    Replies:
    3
    Views:
    273
Tags:

Short URL to this thread: https://techguy.org/1221592

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice