Select a range until a specific value y a specific column

jb01001

New Member
Joined
Oct 15, 2022
Messages
2
Office Version
  1. 2011
  2. 2010
Platform
  1. Windows
I have a table, I need to select a range from a5:l until one row before when the value "e" starts in column H. Value "e" varies every time new data is entered. As selected in the example

The Table is previouly sorted to leave "e" in the final rows.

Please consider the name of the sheet as Ill need to duplicate this for every sheet.

Workbooks("prueba captura nueva - Copy (2).xlsm").Worksheets("carga av")

Once selected, Ill paste special in another workbook, but I have that part done already.
 

Attachments

  • Screen Shot 2022-10-14 at 19.58.34.jpg
    Screen Shot 2022-10-14 at 19.58.34.jpg
    225.2 KB · Views: 31

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
VBA Code:
Sub Find_e()
    Dim ws As Worksheet, rng As Range
    Set ws = Worksheets("carga av")
    Set rng = ws.Range(ws.Cells(5, 1), ws.Cells(ws.Columns("L").Find("e").Row - 1, 12))
    rng.Select  '<< to test
End Sub
 
Upvote 0
Correction
VBA Code:
Sub Find_e()
   Dim ws As Worksheet, rng As Range
    Set ws = Worksheets("carga av")
    Set rng = ws.Range(ws.Cells(5, 1), ws.Cells(ws.Columns("H:H").Find("e").Row - 1, 12))
    rng.Select  '<< to test
End Sub
 
Upvote 0
Correction
VBA Code:
Sub Find_e()
   Dim ws As Worksheet, rng As Range
    Set ws = Worksheets("carga av")
    Set rng = ws.Range(ws.Cells(5, 1), ws.Cells(ws.Columns("H:H").Find("e").Row - 1, 12))
    rng.Select  '<< to test
End Sub
Hello

It returned with this selection...

Thanks!!
 

Attachments

  • Screenshot 2022-10-17 120256.jpg
    Screenshot 2022-10-17 120256.jpg
    192 KB · Views: 24
Upvote 0
Sorry, forgot the Lookat:=xlWhole
VBA Code:
Sub Find_e()
   Dim ws As Worksheet, rng As Range
    Set ws = Worksheets("carga av")
    Set rng = ws.Range(ws.Cells(5, 1), ws.Cells(ws.Columns("H:H").Find("e", Lookat:=xlWhole).Row - 1, 12))
    rng.Select  '<< to test
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,273
Messages
6,177,636
Members
452,787
Latest member
BeeTH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top