SanjayGMusafir
Well-known Member
- Joined
- Sep 7, 2018
- Messages
- 1,503
- Office Version
- 2021
- Platform
- MacOS
Hi Experts
I was writing following VBA code to add a new record. But it's constantly giving 'Type Mismatch' Error with variable x4
The new record has to be "A 1111" (A + space + 4 digits next to last used)
I must be missing some trick.
Also, I'm thinking of VBA to ask how many records to add
And it should repeat the task to add that number of records
Please help
Thanks in Advance
Regards
Sanjay Gulati Musafir
I was writing following VBA code to add a new record. But it's constantly giving 'Type Mismatch' Error with variable x4
The new record has to be "A 1111" (A + space + 4 digits next to last used)
I must be missing some trick.
Also, I'm thinking of VBA to ask how many records to add
And it should repeat the task to add that number of records
Please help
Thanks in Advance
Regards
Sanjay Gulati Musafir
VBA Code:
Sub ClientsAdd()
'
' ClientsAdd Macro
'
'
Call ClientsBottomSr
ActiveCell.Offset(-1, 0).Select
Dim x1 As Range, x2 As Variant, x3 As Variant, x4 As String
Set x1 = ActiveCell
x2 = x1.Value
x3 = Evaluate("--RIGHT(x2,4)+1")
x4 = "A " & x3
'To add new record row
Call ClientsBottomSr
ActiveCell.Value = x4
'To add Current Date to the new created record
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Date
'To go to Tl
Call GoClientsTl
End Sub