+ Reply to Thread
Results 1 to 3 of 3

VBA Program that sums the values of letters (with given values) that are in the word

  1. #1
    Registered User
    Join Date
    10-29-2020
    Location
    Slovenia
    MS-Off Ver
    365
    Posts
    9

    VBA Program that sums the values of letters (with given values) that are in the word

    Hi guys! I have written a program that gives the sum of the values of the letters (i have given the values for the each letter), but it is not working. I would be very happy if someone would help me. Thank you.

    Sub scrabble()

    Dim beseda As Integer
    Dim dolzina As Integer
    Dim presledek As Integer
    Dim crka As Integer
    Dim vsota As Integer
    Dim ena As Integer
    Dim dva As Integer
    Dim tri As Integer
    Dim stiri As Integer
    Dim pet As Integer
    Dim osem As Integer
    Dim deset As Integer


    beseda = Cells(1, 1)
    presledek = " "
    dolzina = Len(beseda)

    ena = "A" = "E" = "I" = "L" = "N" = "O" = "R" = "S" = "T" = "U" = "a" = "e" = "i" = "l" = "n" = "o" = "r" = "s" = "t" = "u"
    dva = "D" = "G" = "d" = "g"
    tri = "B" = "C" = "M" = "P" = "b" = "c" = "m" = "p"
    stiri = "F" = "H" = "V" = "W" = "Y" = "f" = "h" = "v" = "w" = "y"
    pet = "K" = "k"
    osem = "J" = "X" = "j" = "x"
    deset = "Q" = "Z" = "q" = "z"
    vsota = 0

    For crka = 1 To dolzina

    If Mid(beseda, crka, 1) = ena Then
    vsota = vsota + 1
    ElseIf Mid(beseda, crka, 1) = dva Then
    vsota = vsota + 2
    ElseIf Mid(beseda, crka, 1) = tri Then
    vsota = vsota + 3
    ElseIf Mid(beseda, crka, 1) = stiri Then
    vsota = vsota + 4
    ElseIf Mid(beseda, crka, 1) = pet Then
    vsota = vsota + 5
    ElseIf Mid(beseda, crka, 1) = osem Then
    vsota = vsota + 8
    ElseIf Mid(beseda, crka, 1) = deset Then
    vsota = vsota + 10
    ElseIf Mid(beseda, crka, 1) = 0 Then
    vsota = vsota + 0
    Else
    vsota = vsota + 0
    End If

    Next crka
    Cells(2, 1) = vsota

    End Sub

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: VBA Program that sums the values of letters (with given values) that are in the word

    hmmmm...so what is it supposed to do? by the way, I have a client in Slovenia and I will be visiting the country as soon as the virus is over.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: VBA Program that sums the values of letters (with given values) that are in the word

    Here is a macro that will do what your attempted code tried to do...
    Please Login or Register  to view this content.
    Note: You did not say how you were handling the Blank Tile when used in a word. My code assume you will either leave it out or put a blank character rather than the letter at the position it occurs at.

+ 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] adding the values of cells to get a sum with some of the values represented by letters
    By Vachoen in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-26-2019, 09:24 AM
  2. Get unique values from column and get Counts and Sums based on these values
    By khhleung in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-17-2014, 09:58 PM
  3. Replies: 4
    Last Post: 06-13-2013, 09:06 AM
  4. Replies: 2
    Last Post: 03-22-2013, 07:42 AM
  5. descriminate string(letters) values from integer/long (number) values
    By ag273n in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-21-2013, 03:12 AM
  6. How to do sums of values which correspond to names
    By diegosened in forum Excel General
    Replies: 10
    Last Post: 05-07-2012, 11:54 AM
  7. Passing values from Excel To Word and reflect values in Word different places of page
    By csekhar.apps in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2010, 05:53 AM

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