Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro - If bold then multiply by -1

Hi there

I have number in column A

What I want to do is have a macro that can look down the column and if
the cell is bold then multiply the contents by -1 in order for me to
turn it into a negative figure.

I someone can help with this,

Thanks

Andrea

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Macro - If bold then multiply by -1

dim myCell
for each myCell in activesheet.columns(1).cells
if myCell < "" then
if mycell.font.fontstyle = "Bold" then
on error resume next 'just incase there is text in
the cell
myCell = myCell*-1
end if
end if
next myCell

.....not tested but hopefully the above is a good start for you

J


On 31 May, 11:44, "
wrote:
Hi there

I have number in column A

What I want to do is have a macro that can look down the column and if
the cell is bold then multiply the contents by -1 in order for me to
turn it into a negative figure.

I someone can help with this,

Thanks

Andrea



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Macro - If bold then multiply by -1

just tested and looks like you need to use the following line rather
than what I originally said:

myCell.Value = myCell.Value * -1

(I thought value was the default property !!)

J



On 31 May, 11:52, WhytheQ wrote:
dim myCell
for each myCell in activesheet.columns(1).cells
if myCell < "" then
if mycell.font.fontstyle = "Bold" then
on error resume next 'just incase there is text in
the cell
myCell = myCell*-1
end if
end if
next myCell

....not tested but hopefully the above is a good start for you

J

On 31 May, 11:44, "



wrote:
Hi there


I have number in column A


What I want to do is have a macro that can look down the column and if
the cell is bold then multiply the contents by -1 in order for me to
turn it into a negative figure.


I someone can help with this,


Thanks


Andrea- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro - If bold then multiply by -1


Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, TEST_COLUMN).Font.Bold Then
If IsNumeric(.Cells(i, TEST_COLUMN).Value) Then
.Cells(i, TEST_COLUMN).Value = .Cells(i,
TEST_COLUMN).Value * -1
End If
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
oups.com...
Hi there

I have number in column A

What I want to do is have a macro that can look down the column and if
the cell is bold then multiply the contents by -1 in order for me to
turn it into a negative figure.

I someone can help with this,

Thanks

Andrea



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro - If bold then multiply by -1

Beware word-wrap

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, TEST_COLUMN).Font.Bold Then
If IsNumeric(.Cells(i, TEST_COLUMN).Value) Then
.Cells(i, TEST_COLUMN).Value = _
.Cells(i, TEST_COLUMN).Value * -1
End If
End If
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Bob Phillips" wrote in message
...

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long
With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
If .Cells(i, TEST_COLUMN).Font.Bold Then
If IsNumeric(.Cells(i, TEST_COLUMN).Value) Then
.Cells(i, TEST_COLUMN).Value = .Cells(i,
TEST_COLUMN).Value * -1
End If
End If
Next i

End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

wrote in message
oups.com...
Hi there

I have number in column A

What I want to do is have a macro that can look down the column and if
the cell is bold then multiply the contents by -1 in order for me to
turn it into a negative figure.

I someone can help with this,

Thanks

Andrea







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alphabetically list of last names: BOLD, not bold Lerner Excel Discussion (Misc queries) 16 March 1st 09 07:46 PM
Alphabetically list of names BOLD and NOT bold Lerner Excel Discussion (Misc queries) 13 March 1st 09 02:37 PM
Join bold and non-bold text in one cell bkincaid Excel Discussion (Misc queries) 3 March 21st 06 12:58 AM
Excel macro to multiply by same value Recycler29 Excel Worksheet Functions 7 October 12th 05 11:49 AM
How to bold a range of cells using macro George Excel Programming 0 April 30th 04 04:27 PM


All times are GMT +1. The time now is 06:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"