Word Macro Looping Help-code inside

ineedadedt

Board Regular
Joined
Jan 7, 2004
Messages
163
Hi All,

I found a macro code and was trying to modify it below, but I know I am missing a very simple way to loop what I want it to do, but not sure how. I am using this in Word and I want to ask a question of how many pages(times) to run this macro, then paste a picture we would be using to do it. Below the code takes whatever is in the clipboard and pasting it. I need the code below to "take the answer and tell the paste and move to the next section part of the code" to loop until it's done.

Can anyone help me on this? Thanks in advance!

Sub Test1234()

Do
ok = True
no_of_copies = InputBox(Prompt:="Please enter the number of pages in this document.", Title:="Number of pages", Default:="1")

If IsNumeric(no_of_copies) = False Then
MsgBox Prompt:="Non-numeric value entered.", Title:="Invalid value entered"
ok = False
ElseIf no_of_copies < 1 Then
MsgBox Prompt:="Value less than 1 entered.", Title:="Invalid value entered"
ok = False
ElseIf no_of_copies > 1000 Then
MsgBox Prompt:="Value greater than 1000 entered.", Title:="Invalid value entered"
ok = False
End If

Loop Until ok = True

Selection.PasteAndFormat (wdPasteDefault)
Selection.MoveDown Unit:=wdScreen, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=5
End Sub
 

Forum statistics

Threads
1,081,543
Messages
5,359,431
Members
400,526
Latest member
Brook1083

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top