Array clarification, fairly simple

boldcode

Active Member
Joined
Mar 12, 2010
Messages
347
I am using the following piece of code below to populate values into A1, A2 and A3, but for some reason the first value of array gets repeated in cell A2 and A3.

Here is the code:

Code:
With wksNewP
       .Range("A1").Resize(3).Value = Array("Report Name:", "Times Used:", "Dates Used:")
    End With

What I end up with is this:

A1 = Report Name:
A2 = Report Name:
A3 = Report Name:

but what I want is this:

A1 = Report Name:
A2 = Times Used:
A3 = Dates Used:
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Array is a horizontal array. Like this:
Code:
With wksNewP
    .Range("A1").Resize(3).Value = _
        WorksheetFunction.Transpose(Array("Report Name:", _
        "Times Used:", "Dates Used:"))
End With
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,069
Office Version
  1. 2013
Platform
  1. Windows
boldcode,

Try this...

Code:
With wksNewP
For r = 0 To 2
       .Range("A1").Offset(r, 0).Value = Array("Report Name:", "Times Used:", "Dates Used:")(r)    
Next r
End With
Hope that helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,511
Messages
5,596,581
Members
414,079
Latest member
Frills

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
Top