Add an extra row to a variant

johnbird1988

Board Regular
Joined
Oct 6, 2009
Messages
199
Hello,

I have created the below code too populate a userform list box. However I am having problems adding a extra row.

Code:
Function Populate_Listbox_Worksheet() As Variant
    Dim vaData As Variant

nrow = Sheet9.Range("A1048576").End(xlUp).Row

If nrow < Range("ProjName").Row + 1 Then

vaData = Array("0", "(New)")

Else

vaData = Sheet9.Range("A4:B" & nrow).Value

End If

Populate_Listbox_Worksheet = vaData

End Function

In my range I have two columns; ProjectNumber and Project. All project have a number starting from 1. What I would like to do is at the begining add an extra row that is; 0 and (New). With 0 being the ProjectNumber and (New) being the Project.

I have added it into a IF statement because if there are no Projects then the only value in the listbox should be 0 and (New).

How can I add the extra row to my variant table. Been struggling to find anything on the internet too.

Thank you for your help.

John
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,215,454
Messages
6,124,932
Members
449,195
Latest member
Stevenciu

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