Results 1 to 5 of 5

New Issue: Cant convert char string to integer for comparison

Threaded View

  1. #1
    Registered User
    Join Date
    11-21-2023
    Location
    Riverside, California, USA
    MS-Off Ver
    16.0.540
    Posts
    6

    New Issue: Cant convert char string to integer for comparison

    Cant convert char string to integer for comparison.--Please Close Previous thread, not this one.
    The code below did allow me to send the entered Pi data at Colum B. However the comparison to the digits on
    [PiByPosition] row 3 that are integers and the routine places single char of the Pi string, for each value entered on row 5..
    I have tried various CINT() but can't see to get it to convert properly, so I can't know if the entered value is correct or not.

    ========[This below request was resolved- but not the char to integer conversion]==========

    Subroutine is supposed to enter the digits of Pi starting at Column B and so-forth for
    1000 columns (digits I want to learn) .. if starting at 1 for 10 digits,
    then fill the first 10 columns. If starting at 10th digit of Pi then start at the 10th column
    and fill in 1-9 and 11-1000 with "" values in the cells. Excel file attached.
    ===========================================================================================

    Sub Enter_Pi_into_PiByPosition()
    '
    '
    '
    Dim Counter, Counter2, StartNum, EndNum As Integer
    Dim PiEnteredStr As String
    Dim PiChar As String
    Dim PiNumChar As Integer
    '
        Worksheets("Study_Area").Activate
        Worksheets("PiByPosition").Activate
        StartNum = Worksheets("Study_Area").Range("B5").Value
        EndNum = Worksheets("Study_Area").Range("B6").Value
        PiEnteredStr = Worksheets("Study_Area").Range("B18").Value
        Counter2 = 1
        For Counter = 2 To 1001
            If Counter - 1 >= StartNum And Counter <= EndNum Then
                If Counter2 <= EndNum Then
                    PiChar = Mid(PiEnteredStr, Counter2, 1)
                    PiCharNum = CInt(PiChar)
                    Worksheets("PiByPosition").Cells(5, Counter).Value = PiCharNum
                    Counter2 = Counter2 + 1
                End If
            Else
                    Worksheets("PiByPosition").Cells(5, Counter).Value = Null
            End If
        Next Counter
    End Sub
    Attached Files Attached Files
    Last edited by SeanPOsborn; 11-27-2023 at 06:07 PM. Reason: remove remarks in middle of code for clarity

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.
    By H.Gabor in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-26-2018, 06:36 AM
  2. [SOLVED] "1004" error intermitent when trying to fill color in a cell
    By Dragman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2017, 06:20 PM
  3. Replies: 4
    Last Post: 11-13-2015, 09:03 PM
  4. [SOLVED] Ping Status Sheet: "Run-time error '94': Invalid use of null" problem - Excel 2010 VBA
    By mdwbeex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2014, 11:57 AM
  5. [SOLVED] VB error:"1004" Calculate method of range class failed when selecting a cell with Array
    By vayana in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-25-2013, 06:48 PM
  6. [SOLVED] Assign Categories for Time of Day: "Morning", "Afternoon", "Evening"
    By long_shanks in forum Excel General
    Replies: 3
    Last Post: 06-11-2013, 02:59 AM
  7. [SOLVED] error 1004 writing "==================================" to cell
    By darahsten in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 01:16 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