Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2007, 10:05 AM
Registered User
Join Date: Apr 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Looping through rows


I'm sorry if this is a very basic question, but I am just getting to grips with writing my own macros in Excel.

I want the macro to run through column b and if column b = "Divn Totals" to then make everything on that row from column b to column ae bold and shaded in light grey.

The code I have done does this, but only for row 7.


If [b7] = "Divn Totals" Then
Selection.Font.Bold = True
  With Selection.Interior
    .ColorIndex = 15
        .Pattern = xlSolid
   End With
  End If

Any ideas how I can do this for each row in the spreadsheet? Any help would be much appreciated!


Reply With Quote
  #2 (permalink)  
Old April 17th, 2007, 12:14 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts

Here you have Amy

Sub BoldFace_Matching_Text()

Dim r1 As Range

Set r1 = Range("b7:ae7")

For Each c1 In r1

    If c1 = "Divn Totals" Then
    c1.Font.Bold = True
      With c1.Interior
        .ColorIndex = 15
            .Pattern = xlSolid
       End With
    End If

Next c1
End Sub

I have used the range


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping ssaranam SQL Server 2005 2 April 17th, 2008 01:40 AM
looping mrjoka Classic ASP Basics 1 September 26th, 2007 12:21 AM
Looping deepsea007 XSLT 1 June 14th, 2007 12:13 PM
Looping..? dedex C# 2 January 6th, 2005 11:24 PM
Limit rows returned and next rows minhpx General .NET 1 August 12th, 2004 06:25 AM

All times are GMT -4. The time now is 09:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.