#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro Help

Good Day,
I am new to writing Macros and my first one worked to the specific data but
now that the data has change it is getting caught up and need a little help
on how to correct it. The following is where it is getting hung up and I
think I need to make it a little more general but not sure where to start.
Here is what I have:

Do Until ActiveCell.Value = "Consumer Discretionary Total"

Set R = Columns("C").find("Consumer Discretionary Total", LookAt:=xlPart,
MatchCase:=False)
R.Offset(, 1).Select

Any help offered is greatly appreciated.. Thank you for your time
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro Help

Do you mean?

strFind = "Consumer Discretionary Total"
OR
strFind = Range("A1")

Set r = Columns("C").Find(strFind, _
LookAt:=xlPart, MatchCase:=False)
r.Offset(, 1).Select

If this post helps click Yes
---------------
Jacob Skaria


"wblake0926" wrote:

Good Day,
I am new to writing Macros and my first one worked to the specific data but
now that the data has change it is getting caught up and need a little help
on how to correct it. The following is where it is getting hung up and I
think I need to make it a little more general but not sure where to start.
Here is what I have:

Do Until ActiveCell.Value = "Consumer Discretionary Total"

Set R = Columns("C").find("Consumer Discretionary Total", LookAt:=xlPart,
MatchCase:=False)
R.Offset(, 1).Select

Any help offered is greatly appreciated.. Thank you for your time

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro Help

Thanks for the quick response, this is difficult being so new, I probably did
an aweful job explaining what I am trying to do this is what my spread sheet
has in Column C:

Agency ( Agcy )
Agency ( Agcy ) Total
Banking ( Bank )
Banking ( Bank )
Banking ( Bank )
Banking ( Bank ) Total
Basic Industry ( Basc )
Basic Industry ( Basc )
Basic Industry ( Basc ) Total
Brokerage ( Brkg )
Brokerage ( Brkg )
Brokerage ( Brkg ) Total

What I would like to do is go down the column and find everything that ends
in Total and insert a blank row... I hope this explanation is better, I
apologize for being so vague on last post, appreciate the help


"Jacob Skaria" wrote:

Do you mean?

strFind = "Consumer Discretionary Total"
OR
strFind = Range("A1")

Set r = Columns("C").Find(strFind, _
LookAt:=xlPart, MatchCase:=False)
r.Offset(, 1).Select

If this post helps click Yes
---------------
Jacob Skaria


"wblake0926" wrote:

Good Day,
I am new to writing Macros and my first one worked to the specific data but
now that the data has change it is getting caught up and need a little help
on how to correct it. The following is where it is getting hung up and I
think I need to make it a little more general but not sure where to start.
Here is what I have:

Do Until ActiveCell.Value = "Consumer Discretionary Total"

Set R = Columns("C").find("Consumer Discretionary Total", LookAt:=xlPart,
MatchCase:=False)
R.Offset(, 1).Select

Any help offered is greatly appreciated.. Thank you for your time

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Macro Help

Hi

Try if this is what you need.

Sub InsertLineAfterTotal()
Dim LastRow As Long
Dim r As Long

LastRow = Range("C" & Rows.Count).End(xlUp).Row
For r = LastRow To 1 Step -1
If InStr(1, Range("C" & r).Value, "Total", vbTextCompare) Then
Rows(r + 1).EntireRow.Insert
End If
Next
End Sub

Regards,
Per


On 23 Sep., 21:09, wblake0926
wrote:
Thanks for the quick response, this is difficult being so new, I probably did
an aweful job explaining what I am trying to do this is what my spread sheet
has in Column C:

Agency ( Agcy )
Agency ( Agcy ) *Total
Banking ( Bank )
Banking ( Bank )
Banking ( Bank )
Banking ( Bank ) *Total
Basic Industry ( Basc )
Basic Industry ( Basc )
Basic Industry ( Basc ) *Total
Brokerage ( Brkg )
Brokerage ( Brkg )
Brokerage ( Brkg ) *Total

What I would like to do is go down the column and find everything that ends
in Total and insert a blank row... I hope this explanation is better, I
apologize for being so vague on last post, appreciate the help



"Jacob Skaria" wrote:
Do you mean?


strFind = "Consumer Discretionary Total"
OR
strFind = Range("A1")


Set r = Columns("C").Find(strFind, _
LookAt:=xlPart, MatchCase:=False)
r.Offset(, 1).Select


If this post helps click Yes
---------------
Jacob Skaria


"wblake0926" wrote:


Good Day,
I am new to writing Macros and my first one worked to the specific data but
now that the data has change it is getting caught up and need a little help
on how to correct it. The following is where it is getting hung up and I
think I need to make it a little more general but not sure where to start.
Here is what I have:


Do Until ActiveCell.Value = "Consumer Discretionary Total"


*Set R = Columns("C").find("Consumer Discretionary Total", LookAt:=xlPart,
MatchCase:=False)
* *R.Offset(, 1).Select


Any help offered is greatly appreciated.. Thank you for your time- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro Help

Perfect!!
Thanks a lot! This is exactly what I needed...

"Per Jessen" wrote:

Hi

Try if this is what you need.

Sub InsertLineAfterTotal()
Dim LastRow As Long
Dim r As Long

LastRow = Range("C" & Rows.Count).End(xlUp).Row
For r = LastRow To 1 Step -1
If InStr(1, Range("C" & r).Value, "Total", vbTextCompare) Then
Rows(r + 1).EntireRow.Insert
End If
Next
End Sub

Regards,
Per


On 23 Sep., 21:09, wblake0926
wrote:
Thanks for the quick response, this is difficult being so new, I probably did
an aweful job explaining what I am trying to do this is what my spread sheet
has in Column C:

Agency ( Agcy )
Agency ( Agcy ) Total
Banking ( Bank )
Banking ( Bank )
Banking ( Bank )
Banking ( Bank ) Total
Basic Industry ( Basc )
Basic Industry ( Basc )
Basic Industry ( Basc ) Total
Brokerage ( Brkg )
Brokerage ( Brkg )
Brokerage ( Brkg ) Total

What I would like to do is go down the column and find everything that ends
in Total and insert a blank row... I hope this explanation is better, I
apologize for being so vague on last post, appreciate the help



"Jacob Skaria" wrote:
Do you mean?


strFind = "Consumer Discretionary Total"
OR
strFind = Range("A1")


Set r = Columns("C").Find(strFind, _
LookAt:=xlPart, MatchCase:=False)
r.Offset(, 1).Select


If this post helps click Yes
---------------
Jacob Skaria


"wblake0926" wrote:


Good Day,
I am new to writing Macros and my first one worked to the specific data but
now that the data has change it is getting caught up and need a little help
on how to correct it. The following is where it is getting hung up and I
think I need to make it a little more general but not sure where to start.
Here is what I have:


Do Until ActiveCell.Value = "Consumer Discretionary Total"


Set R = Columns("C").find("Consumer Discretionary Total", LookAt:=xlPart,
MatchCase:=False)
R.Offset(, 1).Select


Any help offered is greatly appreciated.. Thank you for your time- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -



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
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 11:13 PM.

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

About Us

"It's about Microsoft Excel"