User Form VBA - Skip a text box from editing

homevest

New Member
Joined
Jul 25, 2019
Messages
8
Hello,

I have a user form that has 96 text boxes labeled R1 through R96.
I have it so once the data is filled in you hit submit and it posts everything from R1 through R94. That part works great.

The reason I dont post R95 or R96 is because I have formulas in the cells.

I can then open the userform and search the data and import it all back in to form and edit as needed. It also pulls in the formula information to R95 and R96. Works Great.

The problem I am having is when I import it back in then use the below below VBA to edit it - it overwrites the R95 and R96 deleting the formulas. I cannot figure out how to have skip over them.


Private Sub cmdEdit_Click()
'declare the variables
Dim findvalue As Range
'error handling
On Error GoTo errHandler:
'check for values
If R1.Value = "" Or R2.Value = "" Then
MsgBox "There is not data to edit"
Exit Sub
End If
'edit the row
Set findvalue = Sheet2.Range("F:F").Find(What:=R4, LookIn:=xlValues).Offset(0, -3)
'if the edit is a name then add it

For x = 1 To cNum
findvalue = Me.Controls("R" & x).Value
Set findvalue = findvalue.Offset(0, 1)
Next
'refresh the listbox
Lookup
'error block
On Error GoTo 0
Exit Sub
errHandler:
MsgBox "An Error has Occurred " & vbCrLf & _
"The error number is: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & "Please notify the administrator"
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I am an idiot - I just realized I can add! Solved my own dang problem

'number of controls to loop through cNum = 94
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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