PC Review


Reply
Thread Tools Rate Thread

Do Until Macro

 
 
Flipper
Guest
Posts: n/a
 
      8th Mar 2010
Hello

I would like to write a "Do Until" macro that will search for the word
"Sub-total" and after finding it. move 7 columns over, then select the next
four cells to the right and apply a certain border to those cells. After
that, I would like that entire row formatted with Bold. I would want to
repeat these steps until it comes to the word Summary.

For example find subtotal (which in this case is in cell B10), then move
over 7 columns to cell I10, select I10:L10, then apply formatting to those
cells. after that select row 10 and apply bold format.

I know this should be easy, but I have never done a looping macro.

Thanks
--
Allan
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      8th Mar 2010
I would use a FINDNEXT macro to find all instances. You don't need to look
for "summary"

Sub findsubtotals()
mc = 1 'col A
lr = Cells(Rows.Count, mc).End(xlUp).Row
'With Range("a1:a" & lr)
With Cells(1, mc).Resize(lr)
Set c = .find(What:="subtotal", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox c.Row
c.Offset(, 7).Resize(, 4).Borders.LineStyle = xlContinuous
Rows(c.Row).Font.Bold = True

Set c = .FindNext(c)
Loop While Not c Is Nothing _
And c.Address <> firstAddress
End If
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Flipper" <(E-Mail Removed)> wrote in message
news:0F9E6FD2-ED4B-443C-BE7F-(E-Mail Removed)...
> Hello
>
> I would like to write a "Do Until" macro that will search for the word
> "Sub-total" and after finding it. move 7 columns over, then select the
> next
> four cells to the right and apply a certain border to those cells. After
> that, I would like that entire row formatted with Bold. I would want to
> repeat these steps until it comes to the word Summary.
>
> For example find subtotal (which in this case is in cell B10), then move
> over 7 columns to cell I10, select I10:L10, then apply formatting to those
> cells. after that select row 10 and apply bold format.
>
> I know this should be easy, but I have never done a looping macro.
>
> Thanks
> --
> Allan


 
Reply With Quote
 
Flipper
Guest
Posts: n/a
 
      11th Mar 2010
What does "mc" mean?
--
Allan


"Don Guillett" wrote:

> I would use a FINDNEXT macro to find all instances. You don't need to look
> for "summary"
>
> Sub findsubtotals()
> mc = 1 'col A
> lr = Cells(Rows.Count, mc).End(xlUp).Row
> 'With Range("a1:a" & lr)
> With Cells(1, mc).Resize(lr)
> Set c = .find(What:="subtotal", LookIn:=xlValues, _
> LookAt:=xlWhole, SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, MatchCase:=False)
>
> If Not c Is Nothing Then
> firstAddress = c.Address
> Do
> MsgBox c.Row
> c.Offset(, 7).Resize(, 4).Borders.LineStyle = xlContinuous
> Rows(c.Row).Font.Bold = True
>
> Set c = .FindNext(c)
> Loop While Not c Is Nothing _
> And c.Address <> firstAddress
> End If
> End With
> End Sub
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Flipper" <(E-Mail Removed)> wrote in message
> news:0F9E6FD2-ED4B-443C-BE7F-(E-Mail Removed)...
> > Hello
> >
> > I would like to write a "Do Until" macro that will search for the word
> > "Sub-total" and after finding it. move 7 columns over, then select the
> > next
> > four cells to the right and apply a certain border to those cells. After
> > that, I would like that entire row formatted with Bold. I would want to
> > repeat these steps until it comes to the word Summary.
> >
> > For example find subtotal (which in this case is in cell B10), then move
> > over 7 columns to cell I10, select I10:L10, then apply formatting to those
> > cells. after that select row 10 and apply bold format.
> >
> > I know this should be easy, but I have never done a looping macro.
> >
> > Thanks
> > --
> > Allan

>
> .
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      11th Mar 2010
Think about it
mc = 1 'col A


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Flipper" <(E-Mail Removed)> wrote in message
news:56135BDE-D237-4DF7-82B0-(E-Mail Removed)...
> What does "mc" mean?
> --
> Allan
>
>
> "Don Guillett" wrote:
>
>> I would use a FINDNEXT macro to find all instances. You don't need to
>> look
>> for "summary"
>>
>> Sub findsubtotals()
>> mc = 1 'col A
>> lr = Cells(Rows.Count, mc).End(xlUp).Row
>> 'With Range("a1:a" & lr)
>> With Cells(1, mc).Resize(lr)
>> Set c = .find(What:="subtotal", LookIn:=xlValues, _
>> LookAt:=xlWhole, SearchOrder:=xlByRows, _
>> SearchDirection:=xlNext, MatchCase:=False)
>>
>> If Not c Is Nothing Then
>> firstAddress = c.Address
>> Do
>> MsgBox c.Row
>> c.Offset(, 7).Resize(, 4).Borders.LineStyle = xlContinuous
>> Rows(c.Row).Font.Bold = True
>>
>> Set c = .FindNext(c)
>> Loop While Not c Is Nothing _
>> And c.Address <> firstAddress
>> End If
>> End With
>> End Sub
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Flipper" <(E-Mail Removed)> wrote in message
>> news:0F9E6FD2-ED4B-443C-BE7F-(E-Mail Removed)...
>> > Hello
>> >
>> > I would like to write a "Do Until" macro that will search for the word
>> > "Sub-total" and after finding it. move 7 columns over, then select the
>> > next
>> > four cells to the right and apply a certain border to those cells.
>> > After
>> > that, I would like that entire row formatted with Bold. I would want
>> > to
>> > repeat these steps until it comes to the word Summary.
>> >
>> > For example find subtotal (which in this case is in cell B10), then
>> > move
>> > over 7 columns to cell I10, select I10:L10, then apply formatting to
>> > those
>> > cells. after that select row 10 and apply bold format.
>> >
>> > I know this should be easy, but I have never done a looping macro.
>> >
>> > Thanks
>> > --
>> > Allan

>>
>> .
>>


 
Reply With Quote
 
Flipper
Guest
Posts: n/a
 
      11th Mar 2010
Sorry to bother, The macro as is doesn't do anything in my workbook and I
just don't understand the language. Would it be possible for you to explain
it to me?

Thanks you
--
Allan


"Flipper" wrote:

> What does "mc" mean?
> --
> Allan
>
>
> "Don Guillett" wrote:
>
> > I would use a FINDNEXT macro to find all instances. You don't need to look
> > for "summary"
> >
> > Sub findsubtotals()
> > mc = 1 'col A
> > lr = Cells(Rows.Count, mc).End(xlUp).Row
> > 'With Range("a1:a" & lr)
> > With Cells(1, mc).Resize(lr)
> > Set c = .find(What:="subtotal", LookIn:=xlValues, _
> > LookAt:=xlWhole, SearchOrder:=xlByRows, _
> > SearchDirection:=xlNext, MatchCase:=False)
> >
> > If Not c Is Nothing Then
> > firstAddress = c.Address
> > Do
> > MsgBox c.Row
> > c.Offset(, 7).Resize(, 4).Borders.LineStyle = xlContinuous
> > Rows(c.Row).Font.Bold = True
> >
> > Set c = .FindNext(c)
> > Loop While Not c Is Nothing _
> > And c.Address <> firstAddress
> > End If
> > End With
> > End Sub
> > --
> > Don Guillett
> > Microsoft MVP Excel
> > SalesAid Software
> > (E-Mail Removed)
> > "Flipper" <(E-Mail Removed)> wrote in message
> > news:0F9E6FD2-ED4B-443C-BE7F-(E-Mail Removed)...
> > > Hello
> > >
> > > I would like to write a "Do Until" macro that will search for the word
> > > "Sub-total" and after finding it. move 7 columns over, then select the
> > > next
> > > four cells to the right and apply a certain border to those cells. After
> > > that, I would like that entire row formatted with Bold. I would want to
> > > repeat these steps until it comes to the word Summary.
> > >
> > > For example find subtotal (which in this case is in cell B10), then move
> > > over 7 columns to cell I10, select I10:L10, then apply formatting to those
> > > cells. after that select row 10 and apply bold format.
> > >
> > > I know this should be easy, but I have never done a looping macro.
> > >
> > > Thanks
> > > --
> > > Allan

> >
> > .
> >

 
Reply With Quote
 
dan dungan
Guest
Posts: n/a
 
      11th Mar 2010
Hi Allen,

I think it means my column.

Dan
 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      11th Mar 2010
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Flipper" <(E-Mail Removed)> wrote in message
news:ED93873D-BC02-4528-A805-(E-Mail Removed)...
> Sorry to bother, The macro as is doesn't do anything in my workbook and I
> just don't understand the language. Would it be possible for you to
> explain
> it to me?
>
> Thanks you
> --
> Allan
>
>
> "Flipper" wrote:
>
>> What does "mc" mean?
>> --
>> Allan
>>
>>
>> "Don Guillett" wrote:
>>
>> > I would use a FINDNEXT macro to find all instances. You don't need to
>> > look
>> > for "summary"
>> >
>> > Sub findsubtotals()
>> > mc = 1 'col A
>> > lr = Cells(Rows.Count, mc).End(xlUp).Row
>> > 'With Range("a1:a" & lr)
>> > With Cells(1, mc).Resize(lr)
>> > Set c = .find(What:="subtotal", LookIn:=xlValues, _
>> > LookAt:=xlWhole, SearchOrder:=xlByRows, _
>> > SearchDirection:=xlNext, MatchCase:=False)
>> >
>> > If Not c Is Nothing Then
>> > firstAddress = c.Address
>> > Do
>> > MsgBox c.Row
>> > c.Offset(, 7).Resize(, 4).Borders.LineStyle = xlContinuous
>> > Rows(c.Row).Font.Bold = True
>> >
>> > Set c = .FindNext(c)
>> > Loop While Not c Is Nothing _
>> > And c.Address <> firstAddress
>> > End If
>> > End With
>> > End Sub
>> > --
>> > Don Guillett
>> > Microsoft MVP Excel
>> > SalesAid Software
>> > (E-Mail Removed)
>> > "Flipper" <(E-Mail Removed)> wrote in message
>> > news:0F9E6FD2-ED4B-443C-BE7F-(E-Mail Removed)...
>> > > Hello
>> > >
>> > > I would like to write a "Do Until" macro that will search for the
>> > > word
>> > > "Sub-total" and after finding it. move 7 columns over, then select
>> > > the
>> > > next
>> > > four cells to the right and apply a certain border to those cells.
>> > > After
>> > > that, I would like that entire row formatted with Bold. I would want
>> > > to
>> > > repeat these steps until it comes to the word Summary.
>> > >
>> > > For example find subtotal (which in this case is in cell B10), then
>> > > move
>> > > over 7 columns to cell I10, select I10:L10, then apply formatting to
>> > > those
>> > > cells. after that select row 10 and apply bold format.
>> > >
>> > > I know this should be easy, but I have never done a looping macro.
>> > >
>> > > Thanks
>> > > --
>> > > Allan
>> >
>> > .
>> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Microsoft Excel Worksheet Functions 3 30th Oct 2009 11:41 AM
::: Sort macro with empty lines at the end. ::: Macro de tri avec lignes vide en bas. infojacques@gmail.com Microsoft Excel Discussion 2 5th Jul 2007 11:40 AM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor karll@swfab.com Microsoft Excel Programming 2 30th Mar 2007 07:48 PM
Run Macro On Open event for report and SetValue Macro has wierd error ThompsonJessical@yahoo.com Microsoft Access Macros 2 2nd Aug 2005 05:51 PM
Start Macro / Stop Macro / Restart Macro Pete Microsoft Excel Programming 2 21st Nov 2003 05:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.