Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Find Last in Range & Insert

I want to find the last "3" in column A after row 65 and insert a row below
this and make this the active row for pasting formula and formatting from
named range "Engineering"

Could someone please help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Find Last in Range & Insert

Try the below procedure.

Sub FindLast3()
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets("Sheet1")
Dim C As Long
For C = 65535 To 65 Step -1 'Won't work if there is a 3 in row 65536.
If WS.Cells(C, 1).Value = 3 Then
WS.Cells(C + 1, 1).Rows.Insert
WS.Cells(C + 1, 1).Activate
Exit Sub
End If
Next C
End Sub

Set WS to equal whatever your worksheet is.

Hope this helps.

Bill Horton

"Karen McKenzie" wrote:

I want to find the last "3" in column A after row 65 and insert a row below
this and make this the active row for pasting formula and formatting from
named range "Engineering"

Could someone please help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Find Last in Range & Insert

Thanks William,

When I run it it seems to insert cells into column A only, it doesn't insert
a complete row.

"William Horton" wrote:

Try the below procedure.

Sub FindLast3()
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets("Sheet1")
Dim C As Long
For C = 65535 To 65 Step -1 'Won't work if there is a 3 in row 65536.
If WS.Cells(C, 1).Value = 3 Then
WS.Cells(C + 1, 1).Rows.Insert
WS.Cells(C + 1, 1).Activate
Exit Sub
End If
Next C
End Sub

Set WS to equal whatever your worksheet is.

Hope this helps.

Bill Horton

"Karen McKenzie" wrote:

I want to find the last "3" in column A after row 65 and insert a row below
this and make this the active row for pasting formula and formatting from
named range "Engineering"

Could someone please help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Find Last in Range & Insert

Karen,

Change the WS.Cells(C + 1, 1).Rows.Insert line to...
WS.Cells(C + 1, 1).Entirerow.insert

That should do it.

Bill Horton

"Karen McKenzie" wrote:

Thanks William,

When I run it it seems to insert cells into column A only, it doesn't insert
a complete row.

"William Horton" wrote:

Try the below procedure.

Sub FindLast3()
Dim WS As Worksheet
Set WS = ThisWorkbook.Worksheets("Sheet1")
Dim C As Long
For C = 65535 To 65 Step -1 'Won't work if there is a 3 in row 65536.
If WS.Cells(C, 1).Value = 3 Then
WS.Cells(C + 1, 1).Rows.Insert
WS.Cells(C + 1, 1).Activate
Exit Sub
End If
Next C
End Sub

Set WS to equal whatever your worksheet is.

Hope this helps.

Bill Horton

"Karen McKenzie" wrote:

I want to find the last "3" in column A after row 65 and insert a row below
this and make this the active row for pasting formula and formatting from
named range "Engineering"

Could someone please help?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find Last in Range & Insert

Sub karen()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 66 Step -1
If Cells(i, 1).Value = 3 Then
Cells(i, 1).Offset(1, 0).EntireRow.Insert
Cells(i, 1).Offset(1, 0).Select
Exit Sub
End If
Next
End Sub
--
Gary''s Student - gsnu200714


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
Find & Replace and Find & Insert macro help needed RS Excel Programming 2 January 29th 07 07:35 AM
find...insert Mike Fogleman Excel Programming 2 October 3rd 06 05:27 AM
Find RangeCopyInsert into Sheet Rob Excel Programming 4 August 31st 06 09:05 PM
Find and insert? leonidas[_64_] Excel Programming 6 August 4th 06 10:04 AM
How do I find a value and insert new value SingaporeSling Excel Worksheet Functions 4 February 4th 05 06:03 AM


All times are GMT +1. The time now is 12:48 PM.

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

About Us

"It's about Microsoft Excel"