Results 1 to 7 of 7

Excel VBA For Creative Problem Solving Part 1 Assignment 4

Threaded View

  1. #1
    Registered User
    Join Date
    12-18-2023
    Location
    USA
    MS-Off Ver
    365
    Posts
    3

    Excel VBA For Creative Problem Solving Part 1 Assignment 4

    VERY new to VBA, first class I have taken so far. I am getting Compile error: "Ambiguous name detected: identifier" when trying to run the assignment below. The assignment doesn't allow you to change the name of subs or functions. The "Identifier" is both a sub and a function. If I change the sub name to "IdentifierS I am able to F8 through the code fine. Is there a way to run the function as named or did I miss something? Thank you in advance.
    Option Explicit
    Dim ColorRow As Integer, NameRow As Integer, ID As String
    
    ' NOTE: For highlighting, use .ColorIndex = 4
    ' For example, Range("A1").Interior.ColorIndex = 4 would color cell A1 green
    
    Sub HighlightRows(ID)
    
    Range(Cells(ColorRow, 1), Cells(ColorRow, 3)).Select
    With Selection.Interior
    .ColorIndex = 4
    End With
    
    
    End Sub
    Sub Example()
    'This is just to show how the Identifier and Key functions below can be utilized in VBA code
    Dim ID As String
    ID = "Y4-824X"
    MsgBox "The identifier is " & Identifier(ID) & " and the key is " & Key(ID)
    End Sub
    
    Sub Identifier()
    Dim ID As String, nr As Integer, i As Integer
    
    nr = WorksheetFunction.CountA(Columns("A:A")) - 1
    For i = 1 To nr
        ID = Range("A" & i + 1)
        If Identifier(ID) = Range("F2") And Key(ID) = Range("F3") Then
        ColorRow = i + 1
        HighlightRows (ID)
         
    End If
    Next i
    
    End Sub
    Function Identifier(ID) As String
    Identifier = Left(ID, 1)
    End Function
    Function Key(ID) As String
    Key = Left(Mid(ID, 4, 4), 1)
    End Function
    
    Sub Reset()
    ' Obtained through a macro recording:
    With Cells.Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    End Sub
    Last edited by davesexcel; 12-19-2023 at 08:38 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By chiky1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2025, 10:35 AM
  2. VBA Excel part 1 Assignment 1
    By boonodno in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2023, 06:35 AM
  3. Help Needed: Excel VBA For Creative Problem Solving Part 1 Assignment 4
    By webcam723 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-04-2023, 08:28 PM
  4. Kindly Help in Solving this Excel Problem
    By yousufsaleem in forum Excel General
    Replies: 1
    Last Post: 12-07-2015, 06:37 PM
  5. Need help in solving a problem using Excel 2007
    By newbieexcel123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2010, 12:59 PM
  6. [SOLVED] i've got a simple excel problem that needs solving...
    By Massive in forum Excel General
    Replies: 8
    Last Post: 05-16-2005, 04:28 AM
  7. Thorny VBA problem. Any creative solution appreciated.
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2005, 06:06 AM

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