Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Robert
The code below should do what you want all I did was set another range from the cell containing "Need header" to the offset column (0,11) then I used an integer to iterate through the elements of the array placing them in the cells. Just a note of interest it is good practice to always declare your variables as it leads to easier to read code and will help out with any nasty spelling mistakes in you code that can take an age to find manually. Option Explicit Dim MyArray As Variant Dim range1 As Range Dim A As Range Dim MyCell, MyRng As Range Dim i As Integer Private Sub CommandButton1_Click() MyArray = Sheets(2).[A1:L1] With Sheets("Sheet3") Set range1 = .Range("A1:A20") For Each A In range1 i = 1 If A.Value = "Need header" Then Set MyRng = Range(A, A.Offset(0, 11))'Set new range For Each MyCell In MyRng MyCell.Value = MyArray(1, i) 'Place array value in cell i = i + 1 'Iterate Integer Next MyCell 'Iterate Cell End If Next A End With End Sub Hope this helps S |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting Range Variable | Excel Programming | |||
Setting a Variable range in VBA | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming | |||
Setting range value to a variable | Excel Programming | |||
Setting up a variable print range | Excel Programming |