Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Beto,
You could do something like this: Sub test() Dim Names As Variant Names = Array("N1", "N2", "N3") Sheets("Sheet1").Range("A1:C1").Value = Names End Sub BTW, you should probably use a different variable name than Names, as Names is the name of a collection of Name objects. In this case, you may want to use vNames or avNames (v for Variant or av for "array of Variants"). -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] Beto wrote: Hi, Can I populate an array in a similar way than this? Dim Names(1 to 3) as String Names=Array("N1","N2","N3") I like something like that instead of: Names(1)="N1": Names(2)="N2": Names(3)="N3" BTW, which one would bethe best way to fill column headings that aren't in any Workbook, just from VBA? Regards, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Can I populate an array in a similar way than this? Dim Names(1 to 3) as String Names=Array("N1","N2","N3") I like something like that instead of: Names(1)="N1": Names(2)="N2": Names(3)="N3" BTW, which one would bethe best way to fill column headings that aren't in any Workbook, just from VBA? Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jake Marx wrote:
Hi Beto, You could do something like this: Sub test() Dim Names As Variant Names = Array("N1", "N2", "N3") Sheets("Sheet1").Range("A1:C1").Value = Names End Sub Worked beatifully... Is there a way to assign comlumn widths in a similar way? As you may find out I'm formatting a sheet for a report. I thought of using a template sheet, but I'm doing this because is harder and helps me to learn more VBA. Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Beto,
Is this what you want Option Base 1 Sub ColumnWidths() Dim aryWidths Dim i As Long aryWidths = Array(10, 15, 22, 34) For i = LBound(aryWidths) To UBound(aryWidths) Columns(i).ColumnWidth = aryWidths(i) Next i End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Beto" wrote in message ... Jake Marx wrote: Hi Beto, You could do something like this: Sub test() Dim Names As Variant Names = Array("N1", "N2", "N3") Sheets("Sheet1").Range("A1:C1").Value = Names End Sub Worked beatifully... Is there a way to assign comlumn widths in a similar way? As you may find out I'm formatting a sheet for a report. I thought of using a template sheet, but I'm doing this because is harder and helps me to learn more VBA. Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Beto,
That works, but I added the bits about lower and upper array bounds as you said you wanted to learn more VBA <G. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Beto" wrote in message ... Beto wrote: Jake Marx wrote: Hi Beto, You could do something like this: Sub test() Dim Names As Variant Names = Array("N1", "N2", "N3") Sheets("Sheet1").Range("A1:C1").Value = Names End Sub Worked beatifully... Is there a way to assign comlumn widths in a similar way? Nevermind, after a lot of trial & error I came up with this: Dim vColumnWidths as Variant vColumnWidths = Array(10, 20, 30) Range("A1:C1").ColumnWidth = vColumnWidths Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Beto wrote:
Jake Marx wrote: Hi Beto, You could do something like this: Sub test() Dim Names As Variant Names = Array("N1", "N2", "N3") Sheets("Sheet1").Range("A1:C1").Value = Names End Sub Worked beatifully... Is there a way to assign comlumn widths in a similar way? Nevermind, after a lot of trial & error I came up with this: Dim vColumnWidths as Variant vColumnWidths = Array(10, 20, 30) Range("A1:C1").ColumnWidth = vColumnWidths Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob Phillips wrote:
Beto, That works, but I added the bits about lower and upper array bounds as you said you wanted to learn more VBA <G. Thanks, Is always better to know more ways to do the same things. Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
Array to Populate ListBox Problem | Excel Discussion (Misc queries) | |||
Populate an array that is a subset of a larger array? | Excel Worksheet Functions | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
variant array containing cel adresses convert to actual ranges-array | Excel Programming |