excel01noob
Board Regular
- Joined
- Aug 5, 2019
- Messages
- 93
- Office Version
- 365
- 2016
Hi
I am trying to setup a Vba code for a big excel file which has accounts in a column A (formatted as number, length either 5, 6 or 7 digits)
I want to copy that account number, add a character at the end (depending on the length, for 5 digits account add character A, for 6 digits account add character K, for 7 digits account add character Z)
I was trying the first part but I am already getting a type mismatch, could you guide me on this?
thank you
Sub LENGHT()
'fills the different colums added
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
If Len(Range("A2:A" & LastRow)) = 5 Then
Range("K2:K" & LastRow) = Range("A2:A" & LastRow) & "A"
End If
End Sub
I am trying to setup a Vba code for a big excel file which has accounts in a column A (formatted as number, length either 5, 6 or 7 digits)
I want to copy that account number, add a character at the end (depending on the length, for 5 digits account add character A, for 6 digits account add character K, for 7 digits account add character Z)
I was trying the first part but I am already getting a type mismatch, could you guide me on this?
thank you
Sub LENGHT()
'fills the different colums added
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
If Len(Range("A2:A" & LastRow)) = 5 Then
Range("K2:K" & LastRow) = Range("A2:A" & LastRow) & "A"
End If
End Sub