VBA - trying to change value of a cell in another sheet in a table using worksheet_change and cells.find

ozasis

New Member
Joined
Feb 3, 2014
Messages
8
Hi all,

I'll outline the details of my set up in dot point form:-

  • I have a sheet called "IAR"
    • It has a table also called "IAR"
    • I have a named range on this sheet called "IARcol" which references the formula "=IAR[[#All],[Job No]]"
  • I have another sheet called "notes"
    • It has a table called "notes"
    • I have a named range on the sheet called "NotesExpectedDate" which references "=Notes[[#All],[NewExpectedDate]]"

I have the following VBA code on the "notes" sheet:-

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim SearchCell As Range
    Dim IARcolumn As Range
    
    Set IARcolumn = Sheets("IAR").Range("IARcol")
                    
    Set SearchCell = Sheets("IAR").IARcolumn.Find(What:=Left(Target.Offset(0, -5), 6).Value, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    
    If Not Intersect(Target, Range("NotesExpectedDate")) Is Nothing Then
        SearchCell.Offset(0, 23).Value = Target.Value
        
    End If
    
End Sub

I cannot for the life of me get it working. I have tried fiddling with bits and pieces, but it just gives me different vba errors.

Any help would be greatly appreciated, as I'm relatively new at creating my own code from scratch. Normally I just modify other people's work to suit, but couldn't find any examples similar to what I require...

Cheers!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I was originally getting the error on the set searchcell line, however I have since broken that variable into multiple variables, and I now get the error when setting the first object...

Code:
Run time error 424, object required

at line:-

Set SearchValue = Left(Target.Offset(0, -5), 6).Value
 
Upvote 0
You dont need the set statement for this particular line, you could just assign
Rich (BB code):
SearchValue = Left(Target.Offset(0, -5), 6).Value
 
Upvote 0
You declared searchcell as a range but now you are trying to set it to a value, there's obviously a conflict
 
Upvote 0
target.value is a date, but the cell offset 5 to the left is a text cell. I tried setting searchvalue as a string and using "Left(Target.Offset(0, -5), 6).Value", but I get "Object Required" as an error.
 
Upvote 0
Its difficult to visualise what you really want to do 'cos but looking at this line, dont you have more arguments than you need with the left function

The left typically functions as left(a,b)you dont need the .value, just
Rich (BB code):
Left(Target.Offset(0, -5), 6)

Can i see the current code you are using, maybe we can analyze/debug it one line at a time and see whats really causing the problem
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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