Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Add Row after a Specific Cell

I have a large spread containing historical information that i update
monthly. I am trying to write a macro that will go to the last month updated
and insert a row beneath it copying the formulas from above. The date is in
column A. Any suggestoins?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add Row after a Specific Cell

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i update
monthly. I am trying to write a macro that will go to the last month

updated
and insert a row beneath it copying the formulas from above. The date is

in
column A. Any suggestoins?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Add Row after a Specific Cell

Tom,

Thanks for the help. I don't think I gave you enough information. The
spread sheet contains blank lines. I was hoping the macro would seek out the
last date updated in column A and add a line after that. Sorry for the
confustion. See below for a condensed example of what the spread sheet looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i update
monthly. I am trying to write a macro that will go to the last month

updated
and insert a row beneath it copying the formulas from above. The date is

in
column A. Any suggestoins?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add Row after a Specific Cell

That's what it does assuming the last date updated is the last filled cell
in column A (which is what I understood you to say).
--
Regards,
Tom Ogilvy

"John" wrote in message
...
Tom,

Thanks for the help. I don't think I gave you enough information. The
spread sheet contains blank lines. I was hoping the macro would seek out

the
last date updated in column A and add a line after that. Sorry for the
confustion. See below for a condensed example of what the spread sheet

looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i update
monthly. I am trying to write a macro that will go to the last month

updated
and insert a row beneath it copying the formulas from above. The date

is
in
column A. Any suggestoins?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Add Row after a Specific Cell

Tom,

Thanks for all the help. Possibly the problem I am having is because there
are several wells that i am tracking on one spread sheet. I played around
with the spread sheet and got it to add a row like it should for the last
well however i need it to add a row for each well. See Below:

Well A

May
Jun
Jul

Well B

May
Jun
Jul

Sorry I didn't explain the problem better.

"Tom Ogilvy" wrote:

That's what it does assuming the last date updated is the last filled cell
in column A (which is what I understood you to say).
--
Regards,
Tom Ogilvy

"John" wrote in message
...
Tom,

Thanks for the help. I don't think I gave you enough information. The
spread sheet contains blank lines. I was hoping the macro would seek out

the
last date updated in column A and add a line after that. Sorry for the
confustion. See below for a condensed example of what the spread sheet

looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i update
monthly. I am trying to write a macro that will go to the last month
updated
and insert a row beneath it copying the formulas from above. The date

is
in
column A. Any suggestoins?








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Add Row after a Specific Cell

John,

You could use a multiple find:

Sub Find_Multiple()
With Worksheets(1).Range("a1:a500")
Set c = .Find("Well", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox "Found Well"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

And in each loop you could do the equivalent of Ctrl + DownArrow and
Ctrl + DownArrow. Than you want to insert a row and selection.Offset(1,0)

You can get the second part of the code using the macro recorder and
than modifying the macro to be more general.

Post back and let us know if this helps...


--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
Tom,

Thanks for all the help. Possibly the problem I am having is because
there
are several wells that i am tracking on one spread sheet. I played around
with the spread sheet and got it to add a row like it should for the last
well however i need it to add a row for each well. See Below:

Well A

May
Jun
Jul

Well B

May
Jun
Jul

Sorry I didn't explain the problem better.

"Tom Ogilvy" wrote:

That's what it does assuming the last date updated is the last filled
cell
in column A (which is what I understood you to say).
--
Regards,
Tom Ogilvy

"John" wrote in message
...
Tom,

Thanks for the help. I don't think I gave you enough information. The
spread sheet contains blank lines. I was hoping the macro would seek
out

the
last date updated in column A and add a line after that. Sorry for the
confustion. See below for a condensed example of what the spread sheet

looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i
update
monthly. I am trying to write a macro that will go to the last
month
updated
and insert a row beneath it copying the formulas from above. The
date

is
in
column A. Any suggestoins?








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Add Row after a Specific Cell

Steve,

That works great for finding a specific date which will always be in Column
A. I tried to combine your and Tom's code so every time it finds the
specified date it adds a row however i am drawing blanks on how to get this
to work. Any ideas on what I'm missing?

Dim rng As Range


Sub Find_Multiple()
With Worksheets(1).Range("a1:a5000")
Set c = .Find("Jul-05", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

Thanks again,

John

"STEVE BELL" wrote:

John,

You could use a multiple find:

Sub Find_Multiple()
With Worksheets(1).Range("a1:a500")
Set c = .Find("Well", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox "Found Well"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

And in each loop you could do the equivalent of Ctrl + DownArrow and
Ctrl + DownArrow. Than you want to insert a row and selection.Offset(1,0)

You can get the second part of the code using the macro recorder and
than modifying the macro to be more general.

Post back and let us know if this helps...


--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
Tom,

Thanks for all the help. Possibly the problem I am having is because
there
are several wells that i am tracking on one spread sheet. I played around
with the spread sheet and got it to add a row like it should for the last
well however i need it to add a row for each well. See Below:

Well A

May
Jun
Jul

Well B

May
Jun
Jul

Sorry I didn't explain the problem better.

"Tom Ogilvy" wrote:

That's what it does assuming the last date updated is the last filled
cell
in column A (which is what I understood you to say).
--
Regards,
Tom Ogilvy

"John" wrote in message
...
Tom,

Thanks for the help. I don't think I gave you enough information. The
spread sheet contains blank lines. I was hoping the macro would seek
out
the
last date updated in column A and add a line after that. Sorry for the
confustion. See below for a condensed example of what the spread sheet
looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i
update
monthly. I am trying to write a macro that will go to the last
month
updated
and insert a row beneath it copying the formulas from above. The
date
is
in
column A. Any suggestoins?









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Add Row after a Specific Cell

John,

I thought you wanted to add a row to each "collection" (well)?

Again the trick is to find the header for each Well and than find the last
row in that section.

What I need to know is:
What do the Well headers look like.
The data that goes into the well.
The number of blank lines in this data.

From your examples in your first post it looked like you had 2 segments of
data in each well.
You appeared to have "Well x" as the header, but now you appear to be
looking for dates. No biggie...

Your code appears to just create a new header...

--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
Steve,

That works great for finding a specific date which will always be in
Column
A. I tried to combine your and Tom's code so every time it finds the
specified date it adds a row however i am drawing blanks on how to get
this
to work. Any ideas on what I'm missing?

Dim rng As Range


Sub Find_Multiple()
With Worksheets(1).Range("a1:a5000")
Set c = .Find("Jul-05", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

Thanks again,

John

"STEVE BELL" wrote:

John,

You could use a multiple find:

Sub Find_Multiple()
With Worksheets(1).Range("a1:a500")
Set c = .Find("Well", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
MsgBox "Found Well"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

And in each loop you could do the equivalent of Ctrl + DownArrow
and
Ctrl + DownArrow. Than you want to insert a row and
selection.Offset(1,0)

You can get the second part of the code using the macro recorder
and
than modifying the macro to be more general.

Post back and let us know if this helps...


--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
Tom,

Thanks for all the help. Possibly the problem I am having is because
there
are several wells that i am tracking on one spread sheet. I played
around
with the spread sheet and got it to add a row like it should for the
last
well however i need it to add a row for each well. See Below:

Well A

May
Jun
Jul

Well B

May
Jun
Jul

Sorry I didn't explain the problem better.

"Tom Ogilvy" wrote:

That's what it does assuming the last date updated is the last filled
cell
in column A (which is what I understood you to say).
--
Regards,
Tom Ogilvy

"John" wrote in message
...
Tom,

Thanks for the help. I don't think I gave you enough information.
The
spread sheet contains blank lines. I was hoping the macro would
seek
out
the
last date updated in column A and add a line after that. Sorry for
the
confustion. See below for a condensed example of what the spread
sheet
looks
like

Well A

Company Name

Various Info
Various Info

May-05 1234 1234 Formula 1234
June-05 1234 1234 Formula 1234
July-05 1234 1234 Formula 1234


"Tom Ogilvy" wrote:

Sub ABC()
Dim rng As Range
Set rng = Rows(Cells(Rows.Count, 1).End(xlUp)(2).Row)
rng.FillDown
On Error Resume Next
rng.SpecialCells(xlConstants).ClearContents
On Error GoTo 0
End Sub

--
Regards,
Tom Ogilvy




"John" wrote in message
...
I have a large spread containing historical information that i
update
monthly. I am trying to write a macro that will go to the last
month
updated
and insert a row beneath it copying the formulas from above.
The
date
is
in
column A. Any suggestoins?











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
Not allowing to continu unless a specific cell has specific answer madubois9 Excel Discussion (Misc queries) 3 October 25th 07 12:45 AM
Link to specific cell in specific Excel file JeroenM Excel Discussion (Misc queries) 3 July 6th 07 10:08 AM
Link from a specific Cell in Excel to a specific para. in Word CathyK Excel Worksheet Functions 0 August 10th 06 04:40 PM
Highlight a row if a specific cell is specific numbers/words sea0221 Excel Worksheet Functions 2 March 9th 05 12:06 AM
How do I make a cell date specific to input a value on a specific. ebuzz13 Excel Discussion (Misc queries) 1 January 18th 05 05:53 PM


All times are GMT +1. The time now is 02:07 AM.

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"