Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1044015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:45:35+00:00 2026-05-16T15:45:35+00:00

I would like to write a macro in vb to select all rows where

  • 0

I would like to write a macro in vb to select all rows where values in column B contain the characters ‘via’. This is my first attempt at macros and not too sure how to begin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:45:36+00:00Added an answer on May 16, 2026 at 3:45 pm

    This one should do it for you (it worked for me) – code adapted from here.

    Option Explicit
    
    Sub SelectByValue(Rng1 As Range, Value As String)
    
        Dim MyRange As Range
        Dim Cell As Object
    
         'Check every cell in the range for matching criteria.
        For Each Cell In Rng1
            If InStr(1, Cell.Text, "via") Then
                If MyRange Is Nothing Then
                    Set MyRange = Range(Cell.Address)
                Else
                    Set MyRange = Union(MyRange, Range(Cell.Address))
                End If
            End If
        Next
         'Select the new range of only matching criteria
        MyRange.Select
    
    End Sub
    
    Sub CallSelectByValue()
    
         'Call the macro and pass all the required variables to it.
         'In the line below, change the Range and the Value as needed
        Call SelectByValue(Range("B1:B10"), "via")
    
    End Sub
    

    How to use it?

    1. Copy the code above.
    2. Open the workbook in which you would like to run this code.
    3. Press Alt + F11 to open the Visual Basic Editor (or VBE).
    4. From the menu, choose Insert-Module.
    5. Paste the code into the code window at right.
    6. Change the Call SelectByValue(Range(“B1:B10″),”via”) line in the code to match your needs.
    7. Close the VBE.

    How to test the code?

    1. Hit Tools-Macro-Macros and double-click CallSelectByValue.

    Before running the Macro:

    alt text

    After running the Macro:

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ok, a few things. First, F# is case-sensitive. Second, the… May 16, 2026 at 9:41 pm
  • Editorial Team
    Editorial Team added an answer This doesn't add any overhead to the normal runtime use… May 16, 2026 at 9:41 pm
  • Editorial Team
    Editorial Team added an answer Tell your co-worker he's a moron. Do an obfuscated SQL… May 16, 2026 at 9:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I would like to write a macro for Notepad++ which should replace char1, char2,
I would like to write a macro in Excel that will write to a
If a=1, b=2, c=3... I would like to write a macro which concatenates them
I'm not very familiar with Clojure/Lisp macros. I would like to write apply-recur macro
I would like to write a program that reads all the unused clusters on
I would like to write an android app that basically layers an overlay on
I would like to write an app on Android to upload my GPS location
I would like to write a code internal to my method that print which
I would like to write my own (toy?) web framework as a learning experience.
I'm trying to write a macro and I have the 2nd half done (tile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.