+ Reply to Thread
Results 1 to 3 of 3

If condition for numbers

  1. #1
    Registered User
    Join Date
    04-20-2018
    Location
    Costa Rica
    MS-Off Ver
    2013
    Posts
    7

    If condition for numbers

    Hi Excel experts,

    I was wondering how a condition can be added in VBA, so let me explain how this might work:

    I have a lot of columns like the next ones and I need only when the text starts with "13000", I need the value in Column B in the same row gets copied/cut and paste to Column A, if that happens, I need to do the same with Column C, gets copied/cut to colunm B., if the number does not starts with "13000", continue with the next row.

    Column A Column B Column C
    1300008815 11132013 BPCS
    100228074 WIR Unidentified deduction
    921010061 PO-162


    All these columns needs to be check until the last row with data.

    Let me know if more details are need.
    Attached Files Attached Files
    Last edited by Perez199202; 04-23-2020 at 01:24 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: If condition for numbers

    The following code looks at the first five digits in each cell in column A to see if it matches "13000". If so, it sets the values of columns A & B to those from columns B & C, then clears column C. Note that in your data it looks like you have some values starting with "13001". This code does not alter those rows, and would need to be adjusted if necessary. (Perhaps look at just the first four characters for "1300" instead?)
    Please Login or Register  to view this content.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,229

    Re: If condition for numbers

    Another option...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to get a sum of numbers each based on a condition?
    By bigscientist in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-30-2019, 01:09 PM
  2. [SOLVED] Average and sum with a condition of minimum numbers.
    By richhhh in forum Excel General
    Replies: 3
    Last Post: 11-16-2016, 04:48 AM
  3. Show all combinations of 'n' numbers with condition(s)?
    By figeroa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2015, 02:45 PM
  4. Mutliply Numbers if a condition is met
    By keenan0928 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-04-2013, 05:56 AM
  5. Find some numbers that satisfy a given condition
    By Atoli in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2012, 01:58 AM
  6. [SOLVED] Numbers condition
    By thair in forum Excel General
    Replies: 18
    Last Post: 06-04-2012, 11:33 AM
  7. condition format between 2 numbers
    By cicihk in forum Excel General
    Replies: 4
    Last Post: 11-20-2010, 05:51 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1