AddRange Code?

emily2309

Board Regular
Joined
Nov 17, 2009
Messages
51
Is there something similar to the additem code, where you can actually add a range from the spreadsheet, rather than a single item, to avoid writing out long lists?
Thanks :)
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Right, new plan: I have changed the food group combo box to radio buttons, so when the radio button has been clicked, it automatically puts something into cell A1. I have used the following code:

With Me.Cbo_FoodItem
If Worksheet("na").Range("A1") = "carbs" Then
Cbo_FoodItem.List = Worksheet("foodtable").Range("B2:B215").Value
End If
End With

However, when i try to test it, i get an error which then highlights the "Worksheet" after IF and says "Sub or Function not defined".
Is there anything wrong with the formulae??
 
Upvote 0
Oh yeah... Thanks :)
Now it's got rid of that error, however it's now coming up with "Run Time Error 9, Subscript out of range"??
 
Upvote 0
Sub FoodInput_open()
FoodInput.Show
End Sub

It's saying the above in red is the problem now, which is the coding for the macro.
 
Upvote 0
Via PM:

Private Sub CommandButton1_Click()
'copy the data to the database
Sheets("na").Range("A1").Value = Cbo_Day.Value
Sheets("na").Range("A3").Value = Cbo_FoodItem.Value
Sheets("na").Range("A4").Value = TxtAmount.Value

'clear the data
UserForm1.Cbo_FoodItem.Value = ""
UserForm1.TxtAmount.Value = ""

End Sub

I get a compile error with UserForm1. What's that?

<!-- / message --><!-- sig -->
 
Upvote 0
Ok i have managed to get the form working, but the food items bit still isn't coming up with food items from the food group i selected with the radio buttons..
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,827
Members
449,190
Latest member
rscraig11

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