VBA to Scroll Down to specific text

emacjake

New Member
Joined
Nov 4, 2014
Messages
29
Hi All

I'm looking for some help with a code to select a range based on its headed and footer in Column A
I've got the below code written to find the text 'Bistro' and select the entire top row of the data,
I'm looking to then scroll down to the next instance of the text 'Bistro' in column A so i can then selection.copy

Can it be written into Something like this "Range(Selection, Selection.End(xlDown)).Select" ?




Cells.Find(What:="bistro", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Offset(0, 5).Activate
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select




Thanks!!!!!!!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi emacJake,

Try the following code:

Rich (BB code):
Sub SelectFindValue()
' Define variables
Dim FindString As String, Rng As Range
' Sets FindString as whatever value you put in the input box
    FindString = InputBox("Enter a Search value")
    If Trim(FindString) <> "" Then
        With Sheets("Sheet1").Cells
' Sets Rng as the cell containing the searched value
            Set Rng = .Find(What:=FindString, _
                            After:=.Cells(1), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious, _
                            MatchCase:=False)
' If the value is found
            If Not Rng Is Nothing Then
' Select the cell
                Rng.Select
            Else
' Otherwise show a message that the value could not be found
                MsgBox "Nothing found"
            End If
        End With
    End If
End Sub
 
Upvote 0
I figured it out,

Gross SalesDiscountsCommissionReturnsNet QtyNet Sales
Bistro
Non-Alcoholic
Non-Alcoholic
Coke 600ml$124-$3$0$034$121
Coke Zero 600ml$29$0$0$08$29
Bistro$100$100$100$10010$100
Outlet 2$29$0$0$08$29
Fanta 600ml$40$0$0$011$40

<tbody>
</tbody>
Outlet 2$100$100$100$10010$100

<tbody>
</tbody>


Data is in the format as above,
I needed to find all columns and rows of outlet data and then insert a a blank row below so i could, Range(Selection, Selection.End(xlDown)).Select, and copy all sales figure to a different page and then do again for every operating outlet.






Dim Outlet As Range


'Bistro
Sheets("Current Stocktake Sales Figures").Select
Range("A1").Select

'Find all bistro Sales figures and insert row underneath


Set Outlet = Cells.Find(What:="bistro", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)

If (Not Outlet Is Nothing) Then

Cells.Find(What:="bistro", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Offset(0, 5).Activate


Cells.FindNext(After:=ActiveCell).Offset(1, 7).Activate
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Selection.insert Shift:=xlDown

'Select all bistro Figures

Cells.Find(What:="bistro", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Offset(0, 5).Activate


Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

'Paste to Bisty Sheet

Sheets("Bisty").Activate
Range("N4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

GoTo Outlet 2
Else
End If
 
Upvote 0

Forum statistics

Threads
1,215,576
Messages
6,125,633
Members
449,242
Latest member
Mari_mariou

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