Results 1 to 5 of 5

Using Arrays With IF-THEN Statements in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    02-03-2011
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2003
    Posts
    4

    Using Arrays With IF-THEN Statements in VBA

    Hello,

    I'm trying to write a macro to copy a cell if the first three integers in the adjacent cell are present in an array. I'm brand new to the concept of arrays, and having a difficult time trying to figure out how to proceed. When I run the code below, I get a Type Mismatch error. I've uploaded an example of the worksheet I'm using.

    Sub mcrFinancialCodeTemplates1()

    Dim aryAMPTH() As Integer
    Dim aryBUs As Integer
    Dim i As Integer

    aryBUs = "180, 181, 182, 184, 185, 751, 752, 753, 754, 755, 757, 758, 759, 762, 765, 766, 771, 773, 774, 776, 777, 810, 811, 813, 817, 818, 818, 819, 820, 822, 825, 831, 833, 834, 835, 838, 839, 950, 951, 952, 953, 954, 955, 956, 957, 959, 960, 962, 963, 964, 965, 967, 968, 969, 970, 971, 974, 975, 976, 977"
    aryAMPTH = Split(aryBUs, ", ")

    For i = LBound(aryAMPTH) To UBound(aryAMPTH)

    Sheets("Main").Select
    Range("A1").Activate
    Do While Not IsEmpty(ActiveCell.Value)
    If (Left(ActiveCell, 3) = aryAMPTH) Then
    ActiveCell.Offset(0, 1).Copy
    Sheets("Sheet1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, -2) = "AMPTH"

    Any help would be appreciated!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. If statements, arrays or VB macro
    By The Kiwi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2012, 07:47 PM
  2. manipulating ranges/arrays with if/then statements?
    By losmi8 in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 11-24-2009, 03:57 AM
  3. [SOLVED] If Statements and Arrays
    By Currie in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 03:05 AM
  4. [SOLVED] RE: If Statements and Arrays
    By Peo Sjoblom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2005, 05:05 PM
  5. [SOLVED] EXCEL ARRAYS & IF STATEMENTS
    By Dan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-24-2005, 02:06 PM

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