Yes no continue box with pasting values in to visible cells

tommyleinen

Board Regular
Joined
Aug 22, 2009
Messages
74
Wondering if anyone can help. I need help to create a macro for putting an "x" value into the visible cells i've filtered on a column.
Since the column may not be the same on each sheet I'd like a pop up message to ask Yes or No to ask if the correct cell is selected at the top of the column.

Here is what I have so far:

Sub addxtovisiblecells()

'put cursor in top cell of range before running this

ans = MsgBox("Is the correct cell selected?", vbYesNo)
If ans = vbYes Then
'Yes your code here

Selection.Value = "x"
ActiveCell.Copy
ActiveCell.Offset(0, 1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, -1).Select
Range.ActiveCell.End(xlUp).Select
ActiveRange.PasteSpecial Paste:=xlPasteValues

Else
End Sub
End If

End Sub

Any help would be much appreciated

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
Sub addxtovisiblecells()
   If MsgBox("Is the correct cell selected?", vbYesNo) = vbYes Then
      Range(ActiveCell, ActiveCell.Offset(, 1).End(xlDown).Offset(, -1)).Value = "x"
   End If
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
I'm not sure how to close this thread but the above from Fluff has been working with no issues, so problem solved and one happy bunny! :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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