Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry for this easy question, but the months of Access Programming has warped
my mind of the many things I remembered in Excel. If I want to find the word "Date", what do I need to add to my VB. Thanks! With ActiveSheet.Range("a1:a50") Set C = .Find("Date", LookIn:=xlValues) ActiveCell.EntireRow.FillUp.Select Selection.Delete shift:=xlUp Secondly, will the second part of my code delete all the rows above the "Date" row? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Option Explicit Sub testme01() Dim RngToSearch As Range Dim LookForWhat As String Dim FoundCell As Range LookForWhat = "Date" With Worksheets("sheet1") Set RngToSearch = .Range("a1:a50") With RngToSearch Set FoundCell = .Cells.Find(what:=LookForWhat, _ after:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ lookat:=xlWhole, _ searchorder:=xlByRows, _ searchdirection:=xlNext, _ MatchCase:=False) End With If FoundCell Is Nothing Then MsgBox "Not Found" Else If FoundCell.Row = 1 Then MsgBox "Found in row 1--not deleted!" Else .Range("A1:A" & FoundCell.Row - 1).EntireRow.Delete End If End If End With End Sub Kou Vang wrote: Sorry for this easy question, but the months of Access Programming has warped my mind of the many things I remembered in Excel. If I want to find the word "Date", what do I need to add to my VB. Thanks! With ActiveSheet.Range("a1:a50") Set C = .Find("Date", LookIn:=xlValues) ActiveCell.EntireRow.FillUp.Select Selection.Delete shift:=xlUp Secondly, will the second part of my code delete all the rows above the "Date" row? -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need to ensure that Date was found and then select that cell for your
code to work... Set C = .Find("Date", LookIn:=xlValues) if C is nothing then msgbox "Not Found" else C.select 'the rest of your code endif -- HTH... Jim Thomlinson "Kou Vang" wrote: Sorry for this easy question, but the months of Access Programming has warped my mind of the many things I remembered in Excel. If I want to find the word "Date", what do I need to add to my VB. Thanks! With ActiveSheet.Range("a1:a50") Set C = .Find("Date", LookIn:=xlValues) ActiveCell.EntireRow.FillUp.Select Selection.Delete shift:=xlUp Secondly, will the second part of my code delete all the rows above the "Date" row? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OMG! Yes, how forgetful of me! Of course I was finding it in my code, but I
wasn't even selecting it, that is why it was being selected! Thanks Jim! (I hate Mondays!) "Jim Thomlinson" wrote: You need to ensure that Date was found and then select that cell for your code to work... Set C = .Find("Date", LookIn:=xlValues) if C is nothing then msgbox "Not Found" else C.select 'the rest of your code endif -- HTH... Jim Thomlinson "Kou Vang" wrote: Sorry for this easy question, but the months of Access Programming has warped my mind of the many things I remembered in Excel. If I want to find the word "Date", what do I need to add to my VB. Thanks! With ActiveSheet.Range("a1:a50") Set C = .Find("Date", LookIn:=xlValues) ActiveCell.EntireRow.FillUp.Select Selection.Delete shift:=xlUp Secondly, will the second part of my code delete all the rows above the "Date" row? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find & Replace: find part cell, replace whole cell | Excel Worksheet Functions | |||
FIND / SEARCH text compare cell to string in 3rd cell | Excel Discussion (Misc queries) | |||
Find First Non blank cell than find column header and return that value | Excel Worksheet Functions | |||
UDF code to find specific text in cell comments, then average cell values | Excel Programming | |||
use find twice to find cell on a specific row | Excel Programming |