Show Cell Values in User Form- VBA

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
821
Office Version
  1. 365
Platform
  1. Windows
I have a workbook with 26 worksheets that could have data in a certain range of cells. What I'm hoping to have is a subroutine in a user form that will look at each sheet in a range of cells V5:Y39 and show a list with no blank rows in a user form. I will have a Button on each sheet that will call the user form.

I also need it to show which sheet and row the data is on.

Any suggestions?

Thanks as always.
 
Last edited:
Almost Perfect ! For some reason it is adding an index column. Can we somehow not show it?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Yes you are right. It shows sheet in column B. For some reason the Index column started showing up after I added the code for setting the Column Widths.
 
Upvote 0
That's right, I made the correction, now you have sheet number, sheet name and row number.
 
Upvote 0
Oh ok. I think I confused myself on this one because my sht number value is the same as my sht name. I think I can figure out how to modify the code to just show one of them. Thanks again!
 
Upvote 0
Dante, is there a setting in the Userform Properties that will let me make changes on a sheet while the userform is showing?
 
Upvote 0
You need to open your UserForm like this:
UserForm1.Show Modeless

Modeless will allow you to work on sheet with Userform Visible

Modify UserForm name as needed.
 
Upvote 0
Code:
Sub PrintUserformShow24()
UserForm10.Show Modeless
End Sub


Code:
Private Sub UserForm()
    Dim sh As Worksheet, s As Long, j As Long
    Dim st As Worksheet
    
    Set st = Sheets("Temp")
    st.Cells.Clear
    st.Range("A1:F1").Value = Array("Sht#", "Row", "Qty.", "Material", "Requestion", "Notes / Comments")
    
    j = 2
    With ListBox1
        .ColumnCount = 7
        .ColumnHeads = True
        For s = 1 To 26
            Set sh = Sheets(s)
            If sh.Name <> st.Name Then
                For i = 5 To 39
                    If WorksheetFunction.CountA(sh.Range("U" & i & ":Y" & i)) > 0 Then
                           st.Cells(j, "A").Value = s
                           'st.Cells(j, "B").Value = sh.Name
                           st.Cells(j, "B").Value = i
                           st.Cells(j, "C").Value = sh.Range("U" & i).Value
                           st.Cells(j, "D").Value = sh.Range("V" & i).Value
                           st.Cells(j, "E").Value = sh.Range("W" & i).Value
                           st.Cells(j, "F").Value = sh.Range("Y" & i).Value
                           j = j + 1
                    End If
                Next
            End If
        Next
        
        st.Columns("A:F").EntireColumn.AutoFit
        For i = 1 To Columns("F").Column
            ancho = ancho & Int(st.Cells(1, i).Width + 3) & ";"
        Next
        .ColumnWidths = ancho
        
        .RowSource = st.Name & "!A2:F" & st.Range("A" & Rows.Count).End(xlUp).Row
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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