Paste to multiple areas/ranges?

R

Rick

This must be a simple thing to do. User select
(highlights) a number of areas in a spreadsheet (holds
down Ctrl to select multiple areas). Then paste a value
into these areas, Say "AA".
Using Help I found out how to select all the individual
areas using -

Sub Select_Areas()
Set rangeToUse = Selection
For Each singleArea In rangeToUse.Areas
singleArea.Select
Next
End Sub

However, I cannot figure out how to paste a value into
each selected area as it goes through the "For" loop?
Any help would be greatly appreciated.

Thanks
Rick
 
D

Don Guillett

I just recorded this
Sub Macro9()
' Macro recorded 4/30/2004 by Don Guillett
Range("A1").Select
Selection.Copy
Range("A1,D9,E6,F6,G8,F10").Select
Range("F10").Activate
ActiveSheet.Paste
End Sub
clean up would be
Range("A1").Copy Range("A1,D9,E6,F6,G8,F10")
 
G

Guest

Don,
thanks for the suggestion. The issue I have is that I
don't know how to get the ranges from the
singleArea.Select statement
The user can select any number of areas.

Thanks
rick
 
D

DNF Karran

Option Explicit

Sub Select_Areas()
Dim SingleArea As Range

For Each SingleArea In Selection
SingleArea.Value = "AA"
Next

End Sub

or more simply

Sub Select_Areas
Selection.Value = "BB"
end sub

Dunca
 
G

Guest

Thanks DNF that works fine.
I tried something like that but I thought you had to
select it first (wrong!).
Your solution is simple and works.

Rick
 
Top