Trying to use selection in a listbox to resize a selection of data

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
I am trying to use a listbox selection to lift only a small segment of the data out of the source of a listbox. I am trying to use the cells argument to pint point the starting spot and then resizing the selection to pull data into another part of the workbook. Unfortunately the resize argument doesn't seem to be pairing well with the cells argument. How can I go about achieving my task? Code is as follows:

VBA Code:
Private Sub TruckOneAdd_Click()

    Dim iRow As Long
    Dim Sh As Worksheet
        
    Set Sh = ThisWorkbook.Sheets("UserFormData")
            
    'code to update the value to the respective fields
    Me.TextBox1.Value = Selected_List + 1
    
    iRow = Me.TextBox1.Value
    
    If Selected_List = 0 Then
        MsgBox "No selection.", vbOKOnly + vbInformation, "Order Select"
        Exit Sub
    End If
    
    Sh.Cells(iRow, 2).Resize(0, 4).Copy ' this does not work

The selected_list is a function I use to figure out the selection that is active in the listbox. I have tried to assign the cell to a range and then resizing but it also does not work.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

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