View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Sub to iterate thru combo box n copy paste n name rangessuccessively in a new sht

Untested...

dim myPict as picture 'is it really a picture


With Worksheets("r")
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
set mypict = .pictures("picturenamehere")
End With

Then you can use:

mypict.copy
destcell.parent.paste

And then position it where you want usint .top, .left stuff.



Max wrote:

Dave,
Many thanks. Tinkered around a little with the code you offered, it works
well (sub below).
I experimented with the recorder & added these 2 lines below (besides the
xlPasteColumnWidths line) as I realized that there was a floating picture (a
legend) within the range Branch which needed to be pasted over as well
(paste special doesn't paste the pic)
DestCell.Select
ActiveSheet.Paste
Would like your expert eye if the above additions are ok as-is (it seems to
work ok),
or, if there's a better way that it should be done
--------------
Sub Gen()
Dim myCell As Range
Dim myRng As Range
Dim RngToCopy As Range
Dim DestCell As Range

Set DestCell = Worksheets.Add.Range("B2")

With Worksheets("r")
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Worksheets("Z")
For Each myCell In myRng.Cells
.Range("H3").Value = myCell.Value
Set RngToCopy = .Range("Branch")
RngToCopy.Copy
DestCell.Select
ActiveSheet.Paste
DestCell.PasteSpecial Paste:=xlPasteValues
DestCell.PasteSpecial Paste:=xlPasteFormats
DestCell.PasteSpecial Paste:=xlPasteColumnWidths
Set DestCell = DestCell.Offset(10, 0)
Next myCell
End With

End Sub


--

Dave Peterson