One button 2 tasks... Place data with one argument

DThib

Active Member
Joined
Mar 19, 2010
Messages
464
Office Version
  1. 365
Platform
  1. Windows
Anyone have the simple answer or complex to this?
Can't get this bit of code to work. It runs throught the If arguments and stops at the "Then" argument.

I am attempting to use the IF to populate TB2, a testbox field, and TB10, a text box field, tied to a spin button. The base is pulled from a column and incremented up or down . At the push of this button the edited TB10 and TB2 should have their contents copied over the existing content.

It works with TB2, I have added the TB10 text and it is throwing an error. Here is my latest code on it.

Help??

Debbie :eeek:

Code:
Private Sub Done_Click()
        Dim Cell As Range, strTemp As String
       With Sheets("Inventory")
           For Each Cell In .Range("B2", .Range("B" & Rows.Count).End(xlUp))
               If Cell = CB1.Text _
                   And Cell.Offset(0, 1) = CB2.Text _
                       And Cell.Offset(0, 2) = CB3.Text _
                           And Cell.Offset(0, 4) = CB4.Text Then
                      Cell.Offset(0, 5).Value = TB2.Text And Cell.Offset(0, 6).Text = TB10.Text
                    Exit Sub
               End If
           Next Cell
       End With
     
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try

Code:
Private Sub Done_Click()
Dim Cell As Range, strTemp As String
With Sheets("Inventory")
    For Each Cell In .Range("B2", .Range("B" & Rows.Count).End(xlUp))
        If Cell = CB1.Text _
            And Cell.Offset(0, 1) = CB2.Text _
                And Cell.Offset(0, 2) = CB3.Text _
                    And Cell.Offset(0, 4) = CB4.Text Then
               Cell.Offset(0, 5).Value = TB2.Text
               Cell.Offset(0, 6).Text = TB10.Text
             Exit Sub
        End If
    Next Cell
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,223
Members
452,896
Latest member
IGT

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