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:
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,932
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,574
Office Version
  1. 365
  2. 2010
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,652
Messages
5,854,960
Members
431,689
Latest member
jacker01

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