Consulting

Results 1 to 5 of 5

Thread: Solved: Range("e1").Row = 5 not e

  1. #1

    Solved: Range("e1").Row = 5 not e

    Hi,

    If I want the value of cell A1 to be e, then the following code is correct.
    Range("a1").Value = Range("e1").column

    My question is that
    If I want the value of cell A1 to be 5, what is the correct code?

    I know that range("a1").value="e" is fine, but I have reason that requires the code has the form I need.
    Ie, Range("a1").Value = Range("e1").??????

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I guess that you don't mean

    [vba]Range("A1").Value = 5[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    not clear.
    i you are wanting to populate A1 with the column letter of a cell then
    [VBA]Range("A1").Value = Left(Range("E1").Address(1, 0), InStr(1, Range("E1").Address(1, 0), "$") - 1)
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Quote Originally Posted by mancubus
    not clear.
    i you are wanting to populate A1 with the column letter of a cell then
    [vba]Range("A1").Value = Left(Range("E1").Address(1, 0), InStr(1, Range("E1").Address(1, 0), "$") - 1)
    [/vba]
    thank you this is exactly what I need.

    I have to say sorry, because the title of this thread is wrong.
    The correct one is
    range("e1").column = 5 not e

  5. #5
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    you're wellcome.

    please mark the thread as "solved" from "Thread Tools" dropdown on top of the page.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •