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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top