Closed Thread
Results 1 to 25 of 25

counting in letters

Hybrid View

  1. #1
    Registered User
    Join Date
    07-31-2007
    Posts
    35

    counting in letters

    I am basically looking for a method to fill in information through VBA in excel into a 2-D grid. Ideally I would like this to work but it does not.

    For row = 1 to 10
         For column = A to D
         Range(column, row) = whatever
         next column
    next row
    Is there a way to do something like this? Basically looking for a way to count through the alphabet.
    Last edited by soce; 09-30-2008 at 03:56 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Thanks for wrapping code.

    Maybe

    Dim Rw As Long, Col As Long
    For Col = 1 To 4
        For Rw = 1 To 10
            Cells(Rw, Col) = Rw & "," & Col
        Next Rw
    Next Col
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    07-31-2007
    Posts
    35
    thanks and sorry about the wrapping, I didn't know how to do that until you replied. I will try your suggesting and see if this helps. THanks again.

  4. #4
    Registered User
    Join Date
    07-31-2007
    Posts
    35
    Quote Originally Posted by VBA Noob View Post
    Thanks for wrapping code.

    Maybe

    Dim Rw As Long, Col As Long
    For Col = 1 To 4
        For Rw = 1 To 10
            Cells(Rw, Col) = Rw & "," & Col
        Next Rw
    Next Col
    VBA Noob
    How does this feature work when I am referencing other sheets? Could you give me an example of how to do this as well?

    my goal is to place equations into cells that reference other sheets cell locations. i know this is wrong but something like this:

    Dim Rw As Long, Col As Long
    For Col = 1 To 4
        For Rw = 1 To 10
            sheets1.Cells(Rw, Col) = sheets2(Rw & "," & Col)
        Next Rw
    Next Col
    Plus I want the sheet# to be a variable so I can count through the sheets. I hope this makes sense.

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    place equations into cells that reference other sheets cell locations
    Why don't you tell us the actual formula ?? then you may get a suitable answer


    Dim Rw As Long, Col As Long
    For Col = 1 To 4
        For Rw = 1 To 10
           With Sheet2
                .Cells(Rw, Col).Formula = _
                "=Sheet1!" & Cells(Rw, Col).Address(0, 0)
            End With
        Next Rw
    Next Col
    Plus I want the sheet# to be a variable so I can count through the sheets. I hope this makes sense
    Nope

    VBA Noob
    Last edited by VBA Noob; 09-30-2008 at 05:20 PM.

  6. #6
    Registered User
    Join Date
    07-31-2007
    Posts
    35
    I didn't include formulas because they are massive and lots of them. There are over 20 formulas but here is an example of one.

    =IF(RC2>R21C5,0,-A2!R[-100]C8*A2!R5C3*R101C6)
    A2 is the name of the sheet that it is referencing. this is just one of many formulas as this workbook is massive. thanks for the help.

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    And the actual cell formula would be

    Why are you doing it in code?

    VBA Noob

  8. #8
    Registered User
    Join Date
    07-31-2007
    Posts
    35

    Using an excel function in a macro

    The excel function

    = ADDRESS(column, row)
    does exactly what I want. However, I want to use this function inside of a macro. I have tried both of the following lines but neither works.

    variable = Application.Address(column, row)
    variable = Application.WorksheetFunction.Address(column, row)
    Does anyone know what I am doing wrong here?

  9. #9
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    If you want to return a Range as a variable, you have to use the set command. There may be better ways to do this, but it is difficult to give you an answer without seeing your code and knowing what you ultimately want to do.

  10. #10
    Registered User
    Join Date
    07-31-2007
    Posts
    35
    Quote Originally Posted by BigBas View Post
    If you want to return a Range as a variable, you have to use the set command. There may be better ways to do this, but it is difficult to give you an answer without seeing your code and knowing what you ultimately want to do.
    The Address function returns the address of the given numbers. Example: Address(2,2) returns $B$2

    I simply want to do this in a macro. I want to feed a variable the address of 2 coordinates and have it store that value.

    variable = Address(2,2)
    Range("A2").value = range(variable).value
    If the cell $B$2 contains the value 8, I would expect the value of 8 to now be in cell A2. Does that help?

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Soce,

    Threads merged as per forum rules.

    As I said if you want a proper answer give a proper example

    VBA Noob

  12. #12
    Registered User
    Join Date
    07-31-2007
    Posts
    35
    Quote Originally Posted by VBA Noob View Post
    Soce,

    Threads merged as per forum rules.

    As I said if you want a proper answer give a proper example

    VBA Noob
    Does my example above help? I simply want to use the function ADDRESS inside a macro. How do I do so? It works perfectly fine in my excel spreadsheets but does not work in the Macro.

  13. #13
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    As per a previous post

    And the actual cell formula would be ?
    VBA Noob

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to sort Single Letters before Double Letters
    By jabberdoo in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-09-2008, 12:18 PM
  2. counting letters but not working in new 2007 excel
    By melaniethomson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-29-2008, 04:20 AM
  3. Counting numberical values mixed with letters: Yes, Yes+1, Yes+2, etc.
    By KatherineMolina in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2008, 02:49 PM
  4. Counting letters
    By samtwilliams in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-08-2007, 01:05 PM
  5. counting letters
    By Pyrex238 in forum Excel General
    Replies: 5
    Last Post: 05-10-2007, 03:54 PM

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