Filling values to columns

  • Thread starter Thread starter Hilla
  • Start date Start date
H

Hilla

Hi,
I am quite new to Excel programming so this question might seem basic..
I need to add values to consecutive columns and i want to do this automatically.
For example i have 5 values that i have to enter to column c,d,e,f,g appropriately.
Does anyone know how to do this?
Thanks,
Hilla
 
Hilla,


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Option Explicit
Sub TEST_1()

Range("C1:G1").Value = Array(1, 2, 3, 4, 5)

End Sub

Sub TEST_2()

Range("C2").Resize(1, 5).Value = Array(10, 20, 30, 40, 50)

End Sub

Sub TEST_3()

Dim RNG As Range
Dim N As Integer

Set RNG = Range("C3")
N = 5
RNG.Resize(1, N).Value = Array(100, 200, 300, 400, 500)

End Sub

Sub TEST_4()

Dim RNG As Range
Set RNG = Range("C4")

RNG.Resize(1, 5).Value = Array([A1], [B1], [A3], [B4], [A5])

End Sub


Sub TEST_5()

Dim i As Integer
Dim X As Variant

X = Array("A8", "A9", "B8", "B9", "B10")

For i = 1 To 5
Range("C5")(1, i).Value = Range(X(i - 1)).Value
Next

End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


--
Regards,
Soo Cheon Jheong
_ _
^¢¯^
--
 
Hilla

There is a myriad of ways you could do this but you question is not full of
detail of what values, is it repeating, etc. Below will do what you ask but
suspect it is not a solution that will work for you

Sub fillRange()
Range("C1:G1").Value = Array(1, 2, 3, 4, 5)
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top