Syntax to refer to a range within an array

MrTeeny

Board Regular
Joined
Jul 26, 2017
Messages
238
I'm doing some things with arrays but stuck on the syntax using the format array(i, 4) can anyone tell me how I would refer to the range array(i,1) to array(i,5) , I'm just trying to set the values to nothing within that range but unsure of the syntax and don't want to set each one separately if needs be, array(i1)="" etc.
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try:
Code:
Dim y as Long
For y = 1 to 5
  arr(i, y) = vbnullstring
Next y
 
Upvote 0
Thanks, I was hoping to avoid looping if possible and hoped they'd be simple syntax similar to setting a range on a sheet like

Code:
[COLOR=#303336][FONT=inherit]Range[/FONT][/COLOR][COLOR=#303336][FONT=inherit]([/FONT][/COLOR][COLOR=#7D2727][FONT=inherit]"A1:B2"[/FONT][/COLOR][COLOR=#303336][FONT=inherit]).[/FONT][/COLOR][COLOR=#303336][FONT=inherit]Value [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#303336][FONT=inherit] ""[/FONT][/COLOR]

But so far not been able to find anything so maybe looping is the only option
 
Upvote 0
You could use Application.Index (search VBA slicing arrays) but for 3 lines of code to clear array elements across 5 columns, why not stick with a loop? I do not believe there would be any noticeable speed loss/gain with a different approach in this case
 
Upvote 0
@Peter_SSs true, I've only ever used it to read out of an array; it was more to suggest "something" other than looping, though unfortunately not a workable suggestion!

Hence for 3 lines of code to write to part of array that doesn't seem big in size, I meant to show you probably do not need anything more complex or written differently
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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