Last cell value copy error

drluke

Active Member
Joined
Apr 17, 2014
Messages
314
Office Version
  1. 365
Platform
  1. Windows
I want to copy the value in the last cell in a column to a cell in another worksheet, and add 1 to it.
I don't know why this code gives a type mismatch error?
VBA Code:
Sub copyValue()

Sheets("Additions").Range("A47").Value = Sheets("Test FAR").Range("A" & Rows.Count).End(xlUp).Value + 1
     
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Sounds like the value it is returning is not a number you can add to.
What does this test return?
VBA Code:
Sub Test()
    MsgBox Sheets("Test FAR").Range("A" & Rows.Count).End(xlUp).Value
End Sub
 
Upvote 0
I would do it like this
VBA Code:
Sub copyValue()

lRow = Sheets("Test FAR").Cells(Rows.Count, 1).End(xlUp).Value
Sheets("Additions").Range("A47").Value = lRow + 1     

End Sub
 
Upvote 0
I would do it like this
VBA Code:
Sub copyValue()

lRow = Sheets("Test FAR").Cells(Rows.Count, 1).End(xlUp).Value
Sheets("Additions").Range("A47").Value = lRow + 1  

End Sub
That shouldn't really make any difference.
And note that they are NOT trying to get the last row number in column A, but rather the value of the last populated cell in column A.
 
Upvote 0
That shouldn't really make any difference.
And note that they are NOT trying to get the last row number in column A, but rather the value of the last populated cell in column A.
Yes I know it shouldn't make a difference but it makes it easier to locate the error
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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