Object Required Error Message

SAleks

New Member
Joined
Oct 27, 2017
Messages
4
Hey Guys,

I really need help with the below code. I have data in column F and it is divided in Columns A:D. I want the macro to stop when the cell value in F= "n/a". I get the Object required error message when I run the code....
Code:
Sub NameSplit()
Dim var As Variant
    Dim rw As Long, i As Long
    With Worksheets("Test")
        For rw = 2 To .Cells(.Rows.Count, "F").End(xlUp).Row
            var = Split(.Cells(rw, "F").Text, ";")
            .Cells(rw, "A").Resize(1, UBound(var) + 1) = var
        Next rw
        
        If Value.Cells(.Rows.Count, "F").Text = "n/a" Then
        Exit Sub
       
        End If
    End With
End Sub

Appreciate your help with that.... I am quite new to vba, so please don't judge me too hard..
thanks a lot in advance
 
Last edited by a moderator:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the forum. :)

Just remove the Value part:

Code:
If .Cells(.Rows.Count, "F").Text = "n/a" Then
 
Upvote 0
thanks, but it does not stop.... forgot to mention that column F is populated with vlookup formula,
 
Upvote 0
should it be
Code:
If .Cells(Rw, "F").Text = "n/a" Then
 
Upvote 0
Oops - yes, almost certainly!
 
Upvote 0
Untested, but how about
Code:
Sub NameSplit()
Dim var As Variant
    Dim rw As Long, i As Long
    With Worksheets("Test")
        For rw = 2 To .Cells(.Rows.Count, "F").End(xlUp).Row
            If Not IsError(.Cells(rw, "F")) Then
            var = Split(.Cells(rw, "F").Text, ";")
            .Cells(rw, "A").Resize(1, UBound(var) + 1) = var
        Next rw
    End With
End Sub
If column F contains an error, the macro will ignore that row & continue.
If you want to quit the macro, when an error is found, let us know
 
Upvote 0
Hey Fluff, it is working, I only added End if before Next rw and the magic happened... :)
thank you so much for the help.. appreciated :)
 
Upvote 0
Glad we could help & thanks for the feedback

As for
I only added End if before Next rw and the magic happened
:oops:
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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