Userform with Formula

god_karthi

New Member
Joined
Jan 10, 2015
Messages
2
I need to make some formula in A coloum and userform is working ok with code below.
while edit but will press then data will save from A coloum.But I want to start B coloum.
Please adjust code.

Data will search from coloum A but will save from B.(To avoid to save coloum A formula)

Code:
    Dim c          As RangeDim rFound     As Range
Dim r          As Long
Dim rng        As Range


Sub FindAll()
Sheets("Master").Select
    Dim strFind As String    'what to find
    Dim rFilter As Range     'range to search
    Set rFilter = Range("a2", Range("a65536").End(xlUp))
    Set rng = Range("a2", Range("a65536").End(xlUp))
    strFind = Me.txtSearchCase.Value
    With Data
     On Error Resume Next
        If Not AutoFilterMode Then Range("a2").AutoFilter
        On Error Resume Next
        rFilter.AutoFilter Field:=1, Criteria1:=strFind
        Set rng = rng.Cells.SpecialCells(xlCellTypeVisible)
        Me.lbxCaseSearch.Clear
        For Each c In rng
            With Me.lbxCaseSearch
                .AddItem c.Value
                .List(.ListCount - 1, 1) = c.Row
                  .List(.ListCount - 1, 2) = c.Offset(, 1)
                   .List(.ListCount - 1, 3) = c.Offset(, 2)
                    .List(.ListCount - 1, 4) = c.Offset(, 3)
            End With
      
        Next c
    End With
   
    Worksheets("Master").AutoFilterMode = False
   ' Me.TextBox1 = ""
End Sub


Private Sub btnCaseSearch_Click()
'search button
Dim c As Range, f As Range
    lbxCaseSearch.Clear
    For Each c In Worksheets("Master").Range("a2", _
        Worksheets("Master").Range("a" & Rows.Count).End(xlUp))
        Set f = c.Find(ComboBox2.Value, LookAt:=xlPart)
         'If InStr(1, c.Value, txtSearchComplaint.Value, vbBinaryCompare) > 0 Then
        If Not f Is Nothing Then
            lbxCaseSearch.AddItem c.Value 'Column A (Team)
            lbxCaseSearch.List(lbxCaseSearch.ListCount - 1, 2) = c.Offset(, 1) 'Column B (Date)
            lbxCaseSearch.List(lbxCaseSearch.ListCount - 1, 3) = c.Offset(, 2) 'Column C (Case #)
            lbxCaseSearch.List(lbxCaseSearch.ListCount - 1, 4) = c.Offset(, 3) 'Column D (Case Officer)
                    
          End If
    Next c
End Sub


Private Sub btnCIClose_Click()
 Unload Me
End Sub


Private Sub btnEdit_Click()
Dim lRow As Long
    Dim ctl As Control
    lRow = Worksheets("Master").Range("a1").CurrentRegion.Rows.Count + 1
    For Each ctl In Frame1.Controls
          If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
                If ctl.Tag <> "" Then
                    ctl.ControlSource = ctl.Tag & lRow
           End If
        End If
    Next ctl
     
End Sub










Private Sub ComboBox2_Change()


End Sub


Private Sub CommandButton90_Click()
Dim lRow As Long
    Dim ctl As Control
    lRow = Worksheets("Master").Range("a1").CurrentRegion.Rows.Count + 1
    For Each ctl In Frame1.Controls
          If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
                If ctl.Tag <> "" Then
                    ctl.ControlSource = ctl.Tag & lRow
           End If
        End If
    Next ctl
    Unload Me
End Sub


Private Sub CommandButton91_Click()
 Unload Me
End Sub


Private Sub CommandButton92_Click()


End Sub




   
   


Private Sub Frame1_Click()
Me.ComboBox1.ListIndex
End Sub


Private Sub lbxCaseSearch_Click()
'big box serach for mouse selection
     'Selection.AutoFilter Field:=1, Criteria1:="<>"
    Dim r As Range, rAll As Range, lRow As Long, nCount As Long
    Dim sTerm As String, ctl As Control
    sTerm = lbxCaseSearch.Value
    With Sheets("Master")
        Set rAll = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
        For Each r In rAll
            If r = sTerm Then
                nCount = nCount + 1
                lRow = r.Row
                For Each objFrame In Me.Controls
                    If TypeName(objFrame) = "Frame" Then
                        For Each ctl In Me(objFrame.Name).Controls
                            If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
                                If ctl.Tag <> "" Then
                                    ctl.ControlSource = ctl.Tag & lRow
                                End If
                            End If
                        Next ctl
                         
                    End If
                Next objFrame
            End If
            If lbxCaseSearch.ListIndex = nCount - 1 Then Exit Sub
        Next
    End With
End Sub




Private Sub btnClearForm_Click()
    Unload Me
    UserForm1.Show
    Load UserForm1
    For Each ctl In Me.Controls
        If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox2" Then
            ctl.Value = ""
        ElseIf TypeName(ctl) = "CheckBox" Then
            ctl.Value = False
        End If
    Next ctl
End Sub

Thanks in advance.
Regards,
gK
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,216,079
Messages
6,128,687
Members
449,464
Latest member
againofsoul

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