+ Reply to Thread
Results 1 to 12 of 12

VBA script to extract data based on multiple columns

  1. #1
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    VBA script to extract data based on multiple columns

    Hello Again,

    Below is my script it is working find on single column but i need to have combination of multiple columns but i failed.

    Can someone enhance the below script. Copy of workbook is attached for your reference.

    Problem Here
    Please Login or Register  to view this content.
    Original code:-
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA script to extract data based on multiple columns

    Hi Abdur_rahman,

    What your code basically does is copy any Diagnosis (column #15) that starts with J03 to a new sheet. What do you want it to do ? Which other column should the code look against or consider ?

  3. #3
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: VBA script to extract data based on multiple columns

    Thank you Nankw for your response.

    I need to check if the J03 diagnosis in column O and if the Age in column AI is less then 6 then extract the data.

    I just need the idea only how should i combine it.

    I have tries like If Not myval Like "J03*" and data(i, 35) < 6 Then but doesn't work.

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA script to extract data based on multiple columns

    If you need to extract data that start with J03 & age < 6 get rid of the Not

    Try the below
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: VBA script to extract data based on multiple columns

    No it doesn't work it is extracting other diagnosis also. Ex: J40, J06, etc..

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA script to extract data based on multiple columns

    Ok, how about this ?

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: VBA script to extract data based on multiple columns

    Thanks nankwa it works.

    If i need to valid 3 columns then again i have add another if condition.

    Thanks.

  8. #8
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA script to extract data based on multiple columns

    Honestly your code is a bit confusing ... Why do you use Not then nothing Else 'your code' ??

    Instead of this
    Please Login or Register  to view this content.
    Why not just write this ?
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: VBA script to extract data based on multiple columns

    Why so complicated? errStr can only get 1 value per row in this setup. Like "J03 *" is the same as left (value, 3).

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: VBA script to extract data based on multiple columns

    Thanks to both of you.

    nankw83 i try your idea but it works on some matching and some skip.

    Vraag let me try your idea and get back you with feedback.

    Thanks once again.

  11. #11
    Forum Contributor
    Join Date
    09-13-2013
    Location
    Saudi Arabia
    MS-Off Ver
    2010, 2013
    Posts
    192

    Re: VBA script to extract data based on multiple columns

    Thanks for your help.

    Might be i have to approach in different way. So i will close this topic and open a new topic. I need to have a list on 1 sheet and validate those items and export the data.

    Thank once again.

  12. #12
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VBA script to extract data based on multiple columns

    Glad to help & thanks for the reps

+ 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. [SOLVED] Extract data from table based on criteria applied to multiple columns
    By Feremartinez in forum Excel General
    Replies: 9
    Last Post: 11-21-2018, 12:34 PM
  2. [SOLVED] Extract Unique values based from multiple columns
    By kobiashi in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-14-2018, 10:10 AM
  3. [SOLVED] vba script to calculate data across multiple columns
    By pchappo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-14-2017, 04:50 AM
  4. [SOLVED] Extract data based on criteria from multiple columns
    By madmoo84 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-08-2017, 07:29 AM
  5. [SOLVED] macro needed to extract specific columns out of multiple columns with their row data
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2014, 12:49 AM
  6. Replies: 11
    Last Post: 10-30-2013, 05:04 AM
  7. Extract Data based on conditions on multiple columns
    By checkoncomp in forum Excel General
    Replies: 6
    Last Post: 07-03-2013, 01:54 PM

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