![]() |
Selecting a number of rows based on the content
Hi there, I have managed this before, and subsequently lost the file I was working on. Being a total amateur in VBA I'm hoping that someone will be able to nudge me in the right direction!: I need to create a range of rows (columns are not required - just entire rows) an example logic is: In Column A, find "Very Likely Projects" - this is the first row in the range In Column A, find "Very Likely Projects Total" - this is the last row in the range. Select the range. simple, yes - can I remember hw to do it? no! any help will be gratefully recieved. thanks in advance -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=487981 |
Selecting a number of rows based on the content
Here is some code
Const sFind As String = "Very Likely Projects" Dim rngStart As Range Dim rngEnd As Range Dim rngAll As Range Set rngStart = Columns(1).Find(sFind) If Not rngStart Is Nothing Then Set rngEnd = Columns(1).Find(sFind & " Total") If Not rngEnd Is Nothing Then Set rngAll = Range(rngStart, rngEnd).EntireRow MsgBox rngAll.Address End If End If -- HTH RP (remove nothere from the email address if mailing direct) "matpj" wrote in message ... Hi there, I have managed this before, and subsequently lost the file I was working on. Being a total amateur in VBA I'm hoping that someone will be able to nudge me in the right direction!: I need to create a range of rows (columns are not required - just entire rows) an example logic is: In Column A, find "Very Likely Projects" - this is the first row in the range In Column A, find "Very Likely Projects Total" - this is the last row in the range. Select the range. simple, yes - can I remember hw to do it? no! any help will be gratefully recieved. thanks in advance -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=487981 |
Selecting a number of rows based on the content
thanks bob, that certainly identifies the range and displays it in a box. I need excel to actually select the rows, as I then need to perform a cut and then insert in a seperately identified row do you know how to do this? -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=487981 |
Selecting a number of rows based on the content
Change
MsgBox rngAll.Address to rngAll.Select -- HTH RP (remove nothere from the email address if mailing direct) "matpj" wrote in message ... thanks bob, that certainly identifies the range and displays it in a box. I need excel to actually select the rows, as I then need to perform a cut and then insert in a seperately identified row do you know how to do this? -- matpj ------------------------------------------------------------------------ matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076 View this thread: http://www.excelforum.com/showthread...hreadid=487981 |
All times are GMT +1. The time now is 05:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com