Forum

Dynamic Column Sear...
 
Notifications
Clear all

Dynamic Column Search for a text and return range

4 Posts
3 Users
0 Reactions
117 Views
(@teja2427)
Posts: 5
Active Member
Topic starter
 

Hello Everyone,

I am trying to find a text in a column range in excel (say A3 to Last row of column A) and once the text is found, I want the range starting from that cell to the last row with data to be cut and paste to a different column (say starting from D3). Now i want to run a search for other text in this new range and once I find the text, I want the range starting from that cell to the last row with data to be cut and paste to a different column (say starting from G3). This will be a loop.

Please help me with this vba code.

Thank you so much in advance.

 
Posted : 08/09/2024 12:53 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

Your criteria are too vague.

Please provide sample data and examples of the results you want.

Regards

Phil

 
Posted : 13/09/2024 8:40 pm
(@teja2427)
Posts: 5
Active Member
Topic starter
 

Hi Philip,

Thank you so much for the response. Please find the sample data set and the required result.

Also, I am trying with the following code(which is a part of a different loop) and when i debug it shows "nothing" in "rngx"

         k=2

        rmc = Sheet2.Cells(i + 2, 40).Value  (rmc will be a integer)

findtext = "Message " & rmc + 1

Set rngx = ActiveSheet.Range(Cells(3, k - 1), Cells(3, lRow2)).Find(findtext, lookat:=xlPart)

k = k + 3

'ActiveSheet.Range("rngX" & lRow2).Cut Destination:=Sheets("Message Check").Cells(4, k)
ActiveSheet.Range("rngX" & lRow2).Cut
ActiveSheet.Cells(4, k).Select
ActiveSheet.PasteSpecial Paste:=xlPasteValues

Next i

 

Please check this and let me know if i am making sense.Required-result.jpgSample-Data.jpg

 
Posted : 15/09/2024 9:34 am
(@keebellah)
Posts: 373
Reputable Member
 

Image files show what you want but are simply not an idea of a sample file

Just make sure non private or sensitive data is removed; which version of excel?

VBA or non-VBA solution?

 
Posted : 16/09/2024 1:46 am
Share: