VBA Paste into (entire) current selection

DutchKevin

Board Regular
Joined
Apr 13, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hello All,
My problem is probably quite easy to code, but so far i'm unsuccesfull.
Here's my case.
I want the user to be able to select a random range on a sheet.
Then with one button he can then "paste" a predefined value into that entire range.
Here's what i have so far. The color works fine, but the data only fills the first cell.

Code:
Sub Fill_V()
    With SELECTION.Interior
        .ColorIndex = 15
        .Pattern = xlSolid
    End With
    ActiveCell.FormulaR1C1 = "V"
End Sub
I also tried:
Code:
ActiveCell.CurrentRegion.Value = "V"
and
Code:
ActiveCell.Range.Value  = "V"
with same result

Looking forward to your ideas.

Thanks
Kevin
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Instead, try:
Code:
Sub Fill_V()
    With Selection
        With .Interior
            .ColorIndex = 15
            .Pattern = xlSolid
        End With
        .Value = "V"
    End With
End Sub
 
Upvote 0
thanks! this bugged me for days already.
Simple and effective, as I had excpected.

and fast reply!
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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