Solved

What is wrong with this code

Posted on 2014-11-04
6
54 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 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 50

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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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…

809 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