Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Clifford Chapman   on Feb 07 In MS Office Category.

  
Question Answered By: Shawna Welch   on Feb 07

To help  get you familiarized with Excel macros, try this:

Turn on the Visual Basic Toolbar
(right-click on toolbars, select Visual Basic)
record a macro (save in THIS workbook, change name if desired)
select a cell
change to Bold.
stop recording

go to VBA Editor (from toolbar)
you should have the Project Builder panel displayed.
Turn on the Debugger toolbar (right-click, select Debug)
find the Modules folder, open Module1
You'll find your macro:
Sub Macro1()
' Macro1 Macro
' Macro recorded 11/2/2007 by
'
Range("B10").Select
Selection.Font.Bold = True
End Sub

change it to:
Sub Macro1()
' Macro1 Macro
' Macro recorded 11/2/2007 by
'
If (Range("B10").Font.Bold) Then
MsgBox "BOLD"
Else
MsgBox "Plain"
End If
End Sub

run the macro (from the toolbar)

Now, you can change this to loop through your data:

sub Macro1
dim R
for R = 2 to 1000
if (cells(R,1) <> "") then '(checks for non-blank rows)
if (cells(R,1).font.bold) then
cells(R,2) = cells(R,2) + 3
end if
end if
next R
end sub

Keep in mind that running this macro will add 3 EACH TIME it is RUN!

see?
wasn't that easy?

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Help for a (Hypothetical) Gambler! Or get search suggestion and latest updates.


Tagged: