Solved

What is wrong with this code

Posted on 2014-11-04
6
50 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
  • 3
  • 2
6 Comments
 
LVL 25

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 48

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 25

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now