+ Reply to Thread
Results 1 to 2 of 2

Output contents of Activecell when Activecell may be string or numeric.

  1. #1
    Registered User
    Join Date
    12-07-2011
    Location
    Cabot, AR
    MS-Off Ver
    Excel 2007
    Posts
    3

    Output contents of Activecell when Activecell may be string or numeric.

    I am looping down a column and getting the activecell value to do some validation on entered fields. The field is a text field but entering a number value is not necessarily an error. If validation fails, I am trying to write a log message using "text" + Activecell + "text" to identify the contents of the cell that are not valid. But if someone enters a numeric value that isn't valid, I get a type mismatch error. If I change it to "text + str(Activecell) + "text" then I get an error when the validation fails for a text entry. Any recommendations on how to write that log message without first doing an IF statement to find out if the value is text or numeric? I tried forcing the column cell properties to be text but still got the same error. Line 12 is where the error occurs.

    1 aocheck = 0
    2 For x = 1 To lcnt
    3 If ActiveCell.Value = lse(x) Then
    4 aocheck = 1
    5 Exit For
    6 End If
    7 Next
    8 If aocheck = 0 Then
    9 erec = erec + 1
    10 errorstr(erec, 1) = "Load Assets"
    11 errorstr(erec, 2) = "Cell" + " " + ActiveCell.Address
    12 errorstr(erec, 3) = "Asset Owner " + Str(ActiveCell) + " not identified as Load Asset Owner in Participant Tab"
    13 End If

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,375

    Re: Output contents of Activecell when Activecell may be string or numeric.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Suggest you upload a sample workbook, too

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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