ActiveCell.Offset

rbobcat1

New Member
Joined
Dec 19, 2011
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Can anyone help, I keep getting an error.

Run-time error '13': Type mismatch
when I debug it highlights the below line;
'ActiveCell.Offset(0, -1).Value = ActiveCell.Offset(-1, -1).Value + 1'

Worksheets("report").Activate
Range("d5").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "" And ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(0, -1).Value = ActiveCell.Offset(-1, -1).Value + 1
End If
ActiveCell.Offset(1, 0).Select
Loop
MsgBox ("Data Transferred!")
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
That would suggest that (at least) one of the cells contains something that can't be converted to a number value.
 
Upvote 0
can you try the below

Code:
Sub Macro1()
    With Columns("C:C")
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C+1"
    End With
    End Sub
 
Last edited:
Upvote 0
Try:
Code:
Sub test()

Dim x       As Long
Dim arr()   As Variant

With Sheets("Sheet1")
    x = .Cells(.Rows.Count, 4).End(xlUp).row
    arr = .Cells(5, 3).Resize(x - 4, 2).Value
    
    For x = LBound(arr, 1) To UBound(arr, 1)
        If LenB(arr(x, 2)) > 0 And LenB(arr(x, 1)) = 0 Then
            If x > LBound(arr, 1) Then
                On Error Resume Next
                arr(x, 1) = arr(x - 1, 1) + 1
                On Error GoTo 0
            End If
        End If
    Next x
    
    .Cells(5, 3).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
End With

Erase arr

MsgBox ("Data Transfered")

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,271
Members
449,219
Latest member
daynle

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