Copy Paste VBA

PivotIdiot

Board Regular
Joined
Jul 8, 2010
Messages
76
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Struggling with some simple code - cant seem to get it right....

VBA Code:
Sub Macro1()
' Macro1 Macro
' Keyboard Shortcut: Ctrl+Shift+M
'
    ActiveCell.Select
    Selection.Copy
    Range(Selection.End(xlDown), Offset(-1)).Select
    ActiveSheet.Paste
    Selection.End(xlDown).Select
End Sub

Im trying copy the contents of the current cell into all the empty cells below, then go to the new cell to repeat.
For example.....
Book1.xlsm
VW
1362DRN90SR6
1363DRN90SR6
1364DRN90SR6
1365DRN90SR6
1366DRN80MK4
1367DRN80MK4
1368DRN80MK4
1369DRN80MK4
1370DRN90SR6
1371DRN
1372DRN
1373DRN
1374DRN
1375DRN80MK4
1376DRN
1377DRN
1378DRN
1379DRN
1380DRN
1381DRN
1382DRN
1383DRN
1384DRN
1385DRN
1386DRN
1387DRN
1388DRN
1389DRN
1390DRN
1391DRN
1392DRN
1393DRN80MK4
1394DRN
1395DRN
1396DRN
1397DRN
Table 1


Any help appreciated
 
Hi, have you checked the below code ?

VBA Code:
Sub copyData()
Dim lastRow As Integer, rowno As Integer
Dim pasteRow As Integer
lastRow = WorksheetFunction.CountA(Worksheets("Sheet2").Range("A:A"))

For rowno = 2 To lastRow
    Sheets("Sheet2").Range("B" & rowno).Copy
    For pasteRow = rowno + 1 To lastRow
        If Sheets("Sheet2").Range("B" & pasteRow) = vbNullString Then
            Sheets("Sheet2").Range("B" & pasteRow).Select
            Sheets("Sheet2").Paste
        Else
            rowno = pasteRow - 1
            Exit For
        End If
    Next
    
Next
End Sub
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Do you mean something like the below?
VBA Code:
Sub FillCell1()
    Dim fCell As Range
    On Error Resume Next

    For Each fCell In Range("W2:W" & Range("V" & Rows.Count).End(xlUp).Row). _
        SpecialCells(xlCellTypeBlanks).Areas
        fCell.Value = fCell(1).Offset(-1).Value
    Next

    On Error GoTo 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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