HELP! Need COPY MACRO: with dialog box with yes/no to continue to next section

hensleyj

New Member
Joined
Apr 2, 2012
Messages
39
Hey everyone,

I am having a bit of a problem trying to get a VBA macro together.

I have a list of data in cell range: J3:J321.

I am trying to make a macro that copies the first section, J3 to J110 then A DIALOG box opens. It then checks cell L69.. if yes, it creates a dialog box and gives the options "continue" or "cancel".

If click continue, it copies J111 TO J163 and checks the next cell if "yes" or "no" if yes, repeats the same process as above. obviously with different cell numbers moving down until it reaches J321 and stops.

I have made 1 script, and it begins the copy commands, then a dialog box opens, and has a button which triggers the next macro. But this is a lot of macros...i thought there might be a more effective way to do this?

any suggestions/help would be appreciated!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Since there was limited information in the OP, this will only illustrate how it can be done. The array and copy to destination are arbitrary solely for illustration.

Code:
Sub t()
Dim rsp As Variant, ary As Variant
ary = Array("J3:J110", "J111:J163", "J164:J230") 'put range addresses in array
With ActiveSheet
    For i = LBound(ary) To UBound(ary)
        .Range(ary(i)).Copy .Cells(Rows.Count, 11).End(xlUp)(2) 'Distination is argitrary for illustration only
        rsp = MsgBox("Do you want to continue?", vbYesNo + vbQuestion, "STOP OPTION")
            If rsp = vbNo Then Exit Sub
    Next
End With
End Sub
This also assumes that the destination will be the same anchor column each copied range. It will post to the next available anchor cell.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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