run time error 9 subscript out of range for other user

Bryancarlo

New Member
Joined
Apr 13, 2021
Messages
21
Hi, Im getting the error even if the sheet is existing. Here is my code:

VBA Code:
Private Sub save_Click()
Dim irow As Long
Dim icol As Long
Dim ws As Worksheet
If TextBox1.Value = "" Or TextBox2.Value = "" Then
MsgBox "Enter Consumer ID and/or Name"
ElseIf status.Value = "" Then
MsgBox "Choose status"
ElseIf auditend.Value = "" Then
MsgBox "Choose status"
Else

Set ws = Worksheets("Prod_data")
'find first row in database
irow = ws.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row
With ws
.Range("A" & irow) = TextBox1.Value
.Range("B" & irow) = TextBox2.Value
.Range("C" & irow) = account.Value
.Range("D" & irow) = status.Value
.Range("E" & irow) = transdate.Value
.Range("F" & irow) = auditdate.Value
.Range("G" & irow) = qa.Value
.Range("H" & irow) = comment.Value
.Range("I" & irow) = auditstart.Value
.Range("J" & irow) = auditend.Value
.Range("BP" & irow) = datetoday.Caption

End With
TextBox1.Value = ""
TextBox2.Value = ""
status.Value = ""
transdate.Value = ""
comment.Value = ""

TextBox1.Enabled = False
TextBox2.Enabled = False
account.Enabled = True
transdate.Enabled = False
auditdate.Enabled = False
qa.Enabled = True
auditstart.Enabled = False
auditend.Enabled = False
status.Enabled = False
save.Enabled = False
CommandButton3.Enabled = False
auditstart.Value = ""
auditend.Value = ""
Lunch.Enabled = True
stop1.Enabled = True
nonprod.Enabled = True
done.Enabled = True
prod.Enabled = True

End If
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You will have to provide a bit more information to elaborate on the problem.
Which line triggers the error and in what circumstances?
if it is the line set ws = .... try to modify it in this way:
VBA Code:
Set ws = Thisworkbook.Worksheets("Prod_data")
Generally you need to reference your objects explicitly to make sure you will get the correct result.
But you need to explain more to get adequate answers.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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