Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What is wrong with this code

Posted on 2014-11-04
6
Medium Priority
?
60 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
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!

 
LVL 26

Accepted Solution

by:
ProfessorJimJam earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

730 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