ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filling values to columns (https://www.excelbanter.com/excel-programming/309054-filling-values-columns.html)

Hilla

Filling values to columns
 
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

Soo Cheon Jheong[_2_]

Filling values to columns
 
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
_ _
^вп^
--




Nick Hodge

Filling values to columns
 
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
HIS


"Hilla" wrote in message
m...
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

Filling values to columns
 
Thanks Alot!!


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com