Sub to iterate thru combo box n copy paste n name ranges successively in a new sht
Dave, thanks for your responses.
The picture is: Picture 3 in sheet: Z
This pic floats over cell M6 which is within the range Branch to be
copied/pasted
Tried fitting in your code (shown below), but couldn't quite get it right
In the new sheet, the pic does get copy/pasted with each iteration but the
pastes are not in the correct position. The pastes all seem to be somewhere
just below the top left cell in the pasted ranges, eg C3, C13, and so on.
The correct positions should be over M6, M16, etc
------------------
Sub Generate()
Dim myCell As Range
Dim myRng As Range
Dim RngToCopy As Range
Dim DestCell As Range
Dim myPict As Picture
'Dim myNewPict As Picture
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 myPict = .Pictures("Picture 3")
myPict.Copy
DestCell.Parent.Paste
With myPict
.Top = .Top
.Left = .Left
'myNewPict.Top = .Top
'myNewPict.Left = .Left
End With
Set DestCell = DestCell.Offset(10, 0)
Next myCell
End With
End Sub
|