ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   EXCEL AND VBA (https://www.excelbanter.com/excel-programming/327262-excel-vba.html)

Cloe

EXCEL AND VBA
 
Hi all.
I use VB6 to generate an Excel report.
I have 3 questions:

1. If .NumberFormat ="@" is for text , what is the NumberFormat for
numerical values? (Integer values).

2. How do I make A1:E1 cells to be centered ? (without causing the whole
column to be centered).

3. How do I put text that contains vbCr (return) in a cell ?

e.g.
First Last Phone
Name Name Number


TIA
Guy



Robert Bruce[_2_]

EXCEL AND VBA
 
Cloe wrote:
Hi all.
I use VB6 to generate an Excel report.
I have 3 questions:

1. If .NumberFormat ="@" is for text , what is the NumberFormat for
numerical values? (Integer values).

2. How do I make A1:E1 cells to be centered ? (without causing the
whole column to be centered).

3. How do I put text that contains vbCr (return) in a cell ?

e.g.
First Last Phone
Name Name Number

Hi,

These should give you a start. Note that if you're using automation you'll
have to make the object references to the range objects much more explicit -
objXL.workbooks("Book.xls").worksheets("Sheet1").R ange("A1") where objXL is
your Excel application object for example.

Range("E2").NumberFormat = "0"

Range("A1:E1").HorizontalAlignment = Excel.xlCenter

With Range("E1")
.FormulaR1C1 = "Wrapped" & VBA.vbLf & "Text"
.WrapText = True
End With

HTH

Rob



Cloe

EXCEL AND VBA
 
Thank you Robert.

Something I learnd today :
I recorded a macro "centering a cell" and then looked into the macro code
and could find the VBA code myself :)

Guy


"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Cloe wrote:
Hi all.
I use VB6 to generate an Excel report.
I have 3 questions:

1. If .NumberFormat ="@" is for text , what is the NumberFormat for
numerical values? (Integer values).

2. How do I make A1:E1 cells to be centered ? (without causing the
whole column to be centered).

3. How do I put text that contains vbCr (return) in a cell ?

e.g.
First Last Phone
Name Name Number

Hi,

These should give you a start. Note that if you're using automation you'll
have to make the object references to the range objects much more
explicit -
objXL.workbooks("Book.xls").worksheets("Sheet1").R ange("A1") where objXL
is
your Excel application object for example.

Range("E2").NumberFormat = "0"

Range("A1:E1").HorizontalAlignment = Excel.xlCenter

With Range("E1")
.FormulaR1C1 = "Wrapped" & VBA.vbLf & "Text"
.WrapText = True
End With

HTH

Rob






All times are GMT +1. The time now is 01:47 PM.

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