Active workbook msgbox

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
128
Hey guys,

I have the following code that copies a cell from the active worksheet to the mentioned one

VBA Code:
inarr = Range("A1:J57")
With Workbooks("Workbook1.xlsx").Worksheets("Test")
loLastRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Range("A" & loLastRow) = inarr(43, 7)
End With

Is there a way to add a confirmation msgbox (Yes/No) at the beginning that mentions the name of the active workbook and to where you are moving the information?

Thanks a lot!!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
adapt to suit your needs

VBA Code:
    Dim rng As Range, inarr As Variant, loLastRow As Long, ws As Worksheet, msg As String
    inarr = Range("A1:J57")
    Set ws = Workbooks("Workbook1.xlsx").Worksheets("Test")
   
    msg = "From = " & ActiveWorkbook.Name & vbCr & vbCr & "to = " & ws.Name & vbTab
    With ws
        loLastRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
        Set rng = .Range("A" & loLastRow)
        msg = msg & rng.Address(0, 0)
        If MsgBox(msg, vbYesNo, "") = vbYes Then
            rng = inarr(43, 7)
        Else
            MsgBox "cancelled"
        End If
    End With
 
Upvote 0
Actually it was really easy

VBA Code:
Answer = Msgbox("please confirm " & activeworkbook.name & activesheet.name , vbquestion + vbyesno

if answer = vbyes then
    Call macro1
Else
    Msgbox "canceled"


Edit: thanks a lot Yongle, thats 10x better :)
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,396
Members
448,891
Latest member
tpierce

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