VBA Help -- how can I copy and paste values from specific cells to into a set cells in another sheet?

Badnames

Board Regular
Joined
Jun 12, 2007
Messages
211
I am trying to copy and paste cells from my first worksheet "Inputs" to a second sheet "Sheet1". I am doing this for rows 1-120. I have been able to do this easily for a range of cells, but now I need to narrow that down to cutting and pasting specific cells to other cells. For example I need to copy b21, h21, and z21 from "Inputs" to a5, d5, and h5 on "Sheet1". Any advice on how I could macro write this portion?


Sub macro1()

Application.ScreenUpdating = False
Dim i As Long
Dim sheet1count As Integer
i = 21
sheet1count = 0
Do While i <= 120

Worksheets("Input").Activate
Range("B" & i).Select
If Range("B" & i) = "MPLS IP Service - IPVPN" Then
Range(("B" & i), ("z" & i)).Select
Application.CutCopyMode = False
Selection.Copy
Worksheets("Sheet1").Activate
Range("A" & (3 + sheet1count)).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
sheet1count = sheet1count + 1
End If

SkipLine:
i = i + 1
Loop
Application.ScreenUpdating = True
Worksheets("Sheet1").Activate

End Sub
 

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.
I need to copy b21, h21, and z21 from "Inputs" to a5, d5, and h5 on "Sheet1".
No need for Copy and Paste. You can do that like this:
Code:
    Sheets("Sheet1").Range("A5") = Sheets("Inputs").Range("B21")
    Sheets("Sheet1").Range("D5") = Sheets("Inputs").Range("H21")
    Sheets("Sheet1").Range("H5") = Sheets("Inputs").Range("Z21")
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

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