Run-Time error 1004 when clearing cells

irrefutable14

New Member
Joined
Mar 2, 2017
Messages
25
I'm scanning ID & Username into "column A1" the vba then moves the cursor to the right to "column b" finally down to
"A2,B2,etc.... But if I make an error of some sort and click on the cell to delete the ID or Username this Run-time error
'1004': Application-defined or object-defined error pops up? What can I do to get rid of it?

Code:
code:
Private Sub Worksheet_Change(ByVal Target As Range)
    MoveRight = MoveRight + 1
    If MoveRight < 2 Then
        Target.Offset(0, 1).Select
    Else
        Target.Offset(1, -MoveRight + 1).Select
        MoveRight = 0
    End If
End Sub
 
If a number is updated in column a of sheet 1 it will look for that value and update it on sheet 2 column a

Code:
Dim CurrentCellValue As Variant

Private Sub Worksheet_Change(ByVal Target As Range)
  Sheets("ASUS CHECKIN").Columns("A").Replace CurrentCellValue, Target.Value, , xlWhole, , , False
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.Count = 1 Then CurrentCellValue = Target.Value
End Sub
 
Last edited:
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Assuming that code works correctly, maybe something like this:
Code:
Dim CurrentCellValue As Variant


Private Sub Worksheet_Change(ByVal Target As Range)
  
'   Make sure it only runs when data is inserted in a single cell
    If Target.Count > 1 Then Exit Sub
    
'   If value updated in column A, run this line of code
    If Target.Column = 1 Then
        Sheets("ASUS CHECKIN").Columns("A").Replace CurrentCellValue, Target.Value, , xlWhole, , , False
    End If

'   Only run when columns A or B are updated with a value
    If Target.Column <= 2 And Target <> "" Then
'       If column A was updated, move to column B in same row
        If Target.Column = 1 Then Target.Offset(0, 1).Select
'       If column B was updated, move to column A in next row
        If Target.Column = 2 Then Target.Offset(1, -1).Select
    End If
  
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.Count = 1 Then CurrentCellValue = Target.Value
End Sub
 
Upvote 0
That works. Only issue is that the first scanned number is mirrored in all cells on sheet2 no matter what number is scanned. So thats progress. However I only need it to find a number and update it. for example
I scan 123456 then in sheet 2 it enters 123456 in column A & Cells a1, a2,a3,etc.

I need to scan in the numbers in the master column a1-b1, a2-b2 etc... Then if the master is updated Find said number within sheet 2 and replace it with the updated value.

sheet one sheet2
123456 is now 321654 123456 found & updated 321654

Thanks soooo much for your help :)
 
Last edited:
Upvote 0
Unfortunately, I really cannot test any "scanning" part. But just so I have a full understanding of how this should all work, can you lay out an actual, simple example of what you "ASUS CHECKIN" sheets looks like, and what exactly should happen?
 
Upvote 0
Here's the entire sheet(s) name "Assign ASUS HERE" & "ASUS CHECKIN".
What I'm trying to get accomplished is on "Assign ASUS HERE" I want to scan numbers into columns A2-B2,then have it automatically
go down a row; A3-B3.. So on. And if a value in "Assign ASUS HERE" Column A is updated. On sheet "ASUS CHECKIN" I'd like it to auto update.

On "assign Tablets HERE" & "IPAD CHECKIN-IN" I'd like Column A in "assign tablets here" to do the same with with ONLY the auto update if there are changes made to column A in "ipad checkin-in"
I thought I just needed a code not, a code that was tailored. Here is the entire workbook.

https://www.dropbox.com/s/2qv3d4n2kt...t123.xlsm?dl=0
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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