Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel from VB, formatting cells 3

Status
Not open for further replies.

petermeachem

Programmer
Aug 26, 2000
2,270
0
0
GB
Can't see how to do this.
I have

Set vbExcel = CreateObject("Excel.Application")
With vbExcel
.WorkBooks.Add
With .ActiveWorkBook

.Sheets(1).Range("A1") = "Customer"

etc etc

End With
End With

I need to do two things
1) Format cells E1:E50 as Currency
I've been struugling away for a couple of hours with things like .Range("E1:E5").NumberFormat = "currency" and only get error messages.
2) Put a few formula in. For instance set a cell to SUM("E1:E5")

I haven't a clue what I'm doing here as have not had to do this before.

Could someone enlighten me?


 
Try this:

.Range("E1:E5").NumberFormat = "$#,##0.00"

Hope this helps you!

Jon
 
When I have a puzzle with Excel I usually record a macro, then hack the code. In this case, try:


Sub MakeCurr
Range("E1:E50").Select
Selection.NumberFormat = "$#,##0.00"
End Sub


Sub SetFormula

Worksheets("Sheet1").Range("A1").Formula = "=SUM($A$4:$A$10)"
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
You're welcome & thanks!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Thanks you helped me also. May 25,2005 thanks for your post. It was just what I was looking for.

Johnwm and jsaliers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top