Array not placing values into correct location

  • Thread starter Thread starter Legacy 93538
  • Start date Start date
L

Legacy 93538

Guest
Hi

I am trying to create an array which loops through the array and for each value in it, it places in the cell of row 1 and go along the columns for value in the array. Currently i have written:

Code:
NCol = 1
For Each sht In Array("InputReference", "Department", "Category", "Section", "DeptVisible", "InputReferenceOrder", _
"LineReference", "LineDescription", "InputDescription", "Format", "Currency", "ColPos", "Input", "InPP", _
"FormulaOverwrite", "Seasonal", "Divide", "Equals", "SectionOverwrite", "LineDescriptionOverwrite", _
"LineJumpReference", "LineJumpText", "HelpText", "ValidationOrder", "Benchmark")
PPNewIR.cells(NCol, 1).Value = sht
Next

However this only puts them into the first cell of the sheet. But i need it to place each value in the array in a new column going along row 1. So for eaxmple it will look like this:
InputReference Department Category Section DeptVisible......

Does anyone know why the code i wrote is just putting them in one cell?

Thanks

Jessicaseymour
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try

Code:
NCol = 1
PPNewIR.Cells(NCol, 1).Resize(, 25).Value = Array("InputReference", "Department", "Category", "Section", "DeptVisible", "InputReferenceOrder", _
"LineReference", "LineDescription", "InputDescription", "Format", "Currency", "ColPos", "Input", "InPP", _
"FormulaOverwrite", "Seasonal", "Divide", "Equals", "SectionOverwrite", "LineDescriptionOverwrite", _
"LineJumpReference", "LineJumpText", "HelpText", "ValidationOrder", "Benchmark")
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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