Using the IF statement with "lcurrentrow" & column

kazmdav

New Member
Joined
Oct 14, 2010
Messages
7
I get error 438 - Object doesn't support this property or method.

Via my "cmdAdd" command button on userform I am checking the current row, column 52 if it contains "1" but I cannot figure out the correct format for the line. Here is my code:

Rich (BB code):
Public lCurrentRow As Long
________________________
Private Sub cmdAdd_Click()
Dim msg As String, Title As String
Dim Config As Integer, Ans As Integer
lCurrentRow = ActiveCell.Row
 
If (ActiveSheet.lCurrentRow & Cells(52) = "1") Then '< code in ERROR 
msg = "You clicked 'Add New Record'. Are you sure you want a add a new record using an existing record?"
Title = "This is a previously written record"
Config = vbYesNo + vbQuestion
Ans = MsgBox(msg, Config, Title)
    If Ans = vbYes Then SaveRow
    If Ans = vbNo Then Exit Sub
End If
If (Cells(0.52) = "") Then
 Call SaveRow
End If
 
' Clear the input form
Call ResetAllFields
 
End Sub

Also, can anyone recommend a good online course for someone struggling at intermediate stage in excel vba, please? I've done a basic face to face 2 day course which I had gone beyond via previous self teaching. However, I am struggling with an application that just keeps throwing me in the deep end & taking up too much precious time with a deadline coming up very quickly.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi

The correct syntax for accessing a cell value is:

Activesheet.Cells(row number, column number).Value

Substitute row number for lCurrent Row and column number for 52, like this:

If ActiveSheet.Cells(lCurrentRow,52).Value = "1" Then

Andrew
 
Upvote 0
Thanks for speedy response Andrew . That fixed up that line of code. :p

I have quite a number of other issues with my coding within the application but am desparately trying to figure out before asking here. :confused:
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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