Solved

What is wrong with this code

Posted on 2014-11-04
6
58 Views
Last Modified: 2014-11-19
Hi

Could somebody please help with the below code. When this is run it returns FALSE


    ActiveCell.Offset(-1, 0).Range("A1").Select
    ActiveCell.FormulaR1C1 = _
    Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    Selection.Style = "Currency"
    Selection.Font.Bold = True
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    Selection.Borders(xlEdgeLeft).LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Selection.Borders(xlEdgeRight).LineStyle = xlNone
    Selection.Borders(xlInsideVertical).LineStyle = xlNone
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    Workbooks.Item("Main Data Sheet.xls").Close
 
What we want it to do is just format the cell as currency, bold & underline.

Thanks in advance

Ajae
0
Comment
Question by:ajaeclarke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:ProfessorJimJam
ID: 40423315
Use only this part
Select cells and then run this

Sub test ()
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    Selection.Style = "Currency"
    Selection.FNot.bold=true
End sub
0
 
LVL 1

Author Comment

by:ajaeclarke
ID: 40423456
Hi ProfessorJimJam
Sorry....where should I be putting that part?
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 40423631
Hi,

You should replace all the text between the lines Sub (something) and End Sub of your code

with

Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    Selection.Style = "Currency"
    Selection.Font.Bold=True

Regards
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Accepted Solution

by:
ProfessorJimJam earned 500 total points
ID: 40423662
You need to copy this code and paste it in a module

if you do not know how to insert a module. then please see attached word document.

Sub test()

Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    Selection.Style = "Currency"
    Selection.Font.Bold = True
End Sub

Open in new window

InsertMod.docx
0
 
LVL 1

Author Comment

by:ajaeclarke
ID: 40424778
Sorry I wasn't very clear. We need the rest of the code as is. We just don't know why it is returning FALSE.
0
 
LVL 1

Author Comment

by:ajaeclarke
ID: 40454337
Sorry for the delay in getting back to this.

Thanks for the help and got it working like ProfessorJimJam suggested.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question