Code to Paste an Array

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
With this code:
Rich (BB code):
    If rtarget.Name = "CUEALL" Then
        If rtarget.Fill.ForeColor.RGB = RGB(255, 255, 255) Then
            MsgBox "Caller: " & rtarget.Name
            myDocument.Shapes.Range(Array("CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT", "CUEALL")).Fill.ForeColor.RGB = RGB(255, 0, 0)
            wshvar.Range("T" & nextrow) = Application.Transpose(Array("CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT"))
        Else
            myDocument.Shapes.Range(Array("CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT", "CUEALL")).Fill.ForeColor.RGB = RGB(255, 255, 255) 'ON to OFF
            MsgBox "OFF"
        End If
    ElseIf rtarget.Name = "CULALL" Then

The idea is to paste the array or values "CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT" starting at the next open cell (nextrow = wshvar.Cells(Rows.Count, "T").End(xlUp).Row + 1) in column T.

This is not happening. Only "CUEDR" is being pasted there. The other values are missing in the column.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You don't paste arrays, you put the values from the array in cells.

To do that you need to resize the destination range to the same size as the array.

In this case I think you need to resize by 6 columns, or 6 rows - that isn't really clear.
 
Upvote 0
For lack of better words I used the term pasting ... taking values from one place and putting them where I need them. The array is transposed at the next available cell in column T ... I took transpose as being filling by the row.
How do I resize?
 
Upvote 0
For rows.
Code:
wshvar.Range("T" & nextrow).Resize(6).Value = ...

For columns.
Code:
wshvar.Range("T" & nextrow).Resize(,6).Value = ...
 
Upvote 0
OK ... I got six 6 rows populated of column T, but of just the first value in the array "CUEDR"
Code:
wshvar.Range("T" & nextrow).Resize(6).Value = (Array("CUEDR", "CUEDT", "CUEFR", "CUEFT", "CUECR", "CUECT"))
 
Upvote 0
Why did you remove Application.Transpose?
 
Upvote 0
Good question ... but your subtle hint Norie resolved the issue. LOL.
Thanks!

Jenn
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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