How to load a range into a Variant

tonywill

New Member
Joined
Apr 17, 2011
Messages
1
I have the folowing snippet of code which I have been trying to adapt to reading in about 300 different words from a range into a variant.

Option Explicit
Option Compare Text
Sub Highlightnouns()
Application.ScreenUpdating = False
Dim myWords As Variant
;
;

' would be nice to be able to load from a range instead typing words into here
myWords = Array("Drill", "Filter", "oil", "seal", "Gearbox")

I have tried various ways to do this but none work,
tony
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try something like this...
Code:
Dim myWords As Variant
[COLOR="Red"]myWords = Range("A1:A5")[/COLOR]

MsgBox myWords(1, 1) & vbLf & _
       myWords(2, 1) & vbLf & _
       myWords(3, 1) & vbLf & _
       myWords(4, 1) & vbLf & _
       myWords(5, 1)
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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