RowSource Property Issues

albertocarrillom

New Member
Joined
Apr 24, 2024
Messages
5
Office Version
  1. 365
I am new developing VBA programs. I am creating an Inventory of my job, sometimes the programs work perfectly fine, but some other the program does not work out.

It appears this message:
Screenshot 2024-04-24 115911.png


I am attaching my code, my problem is in the .RowSource = rg.Address:

Private Sub AddButton_Click()
Dim frm As New formStockDetailsNew
frm.Show
Call AddDataToListBox
End Sub
Private Sub ButtonRemove_Click()
Call RemoveRow
End Sub
Private Sub EditButton_Click()
Call EditRow
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub

Private Sub listboxStock_Click()

End Sub

Private Sub NewButton_Click()
Call NewRow
End Sub
Private Sub RemoveButton_Click()
Call DeleteRow(listboxStock.ListIndex)
End Sub
Private Sub UserForm_Initialize()
Call AddDataToListBox
Me.Width = 800
Me.Height = 340
End Sub
Private Sub AddDataToListBox()
'Get the Range
Dim rg As Range
Set rg = GetRange()

'Link the data to the ListBox
With listboxStock

.RowSource = rg.Address
.ColumnCount = rg.Columns.Count
.ColumnWidths = "100;160;80;60;60;80;90;110"
.ColumnHeads = True
.ListIndex = 0
End With
End Sub
Private Sub EditRow()
Dim frm As New formStockDetailsEdit
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub NewRow()
Dim frm As New AddQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub RemoveRow()
Dim frm As New RemoveQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub

The help will be really appreciated.

Cheers
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
What is this? Set rg = GetRange() How many columns and rows is this returning?
 
Upvote 0
When you run into memory issues it's most likely due to loading too much into variables and form controls. So, How may rows and columns is that GetRange() returning
 
Upvote 0
Ok, so that is not it.

When you click on the Debug button what line gets highlighted in yellow? This line? .RowSource = rg.Address
 
Upvote 0
When the row is highlighted and you hover over rg.address, what does it show as the address. Let's make sure that the address provided is on the ACTIVESHEET. Meaning, if the address provided comes from a different sheet then the activesheet, you'll get nothing or erroneous results.

I'm running out of options.
 
Upvote 0

Forum statistics

Threads
1,217,296
Messages
6,135,692
Members
449,958
Latest member
natlmc4877

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