Results 1 to 4 of 4

Thread: [RESOLVED] Write to a specific cell

  1. #1

    Thread Starter
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Resolved [RESOLVED] Write to a specific cell

    I've got a row selected / activated... now I need to write some data into that selected row.

    How would I put the data, say,
    temp1 into the selected row's column b
    temp2 into the selected row's column c
    etc... etc...

    then, at the end, i need to select the data in columns a-e (so that it can be pasted into another spreadsheet)...

    any ideas on code for this? i'm a complete n00b


    -Matthew-

  2. #2

    Thread Starter
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Re: Write to a specific cell

    i would think this would be *easy* in Excel VBA....

    perhaps not though?


    -Matthew-

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Write to a specific cell

    For the first part, try this:
    VB Code:
    1. Dim lngSelectionRow as Long
    2. lngSelectionRow = Selection.Row
    3. With Worksheets("[U]sheetname[/U]")
    4.  .Range("B" & lngSelectionRow).Value = temp1
    5.  .Range("C" & lngSelectionRow).Value = temp2
    6. End With
    And for the second, either of these:
    VB Code:
    1. Worksheets("[U]sheetname[/U]").Range("A" & lngSelectionRow & ":E" & lngSelectionRow).Select
    2.  
    3. Worksheets("[U]sheetname[/U]").Range("A" & lngSelectionRow & ":E" & lngSelectionRow).Copy Worksheets("[U]target sheetname[/U]").Range("[U]A1[/U]")

  4. #4

    Thread Starter
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Re: Write to a specific cell

    works like a champ! thanks!


    -Matthew-

Posting Permissions

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



Click Here to Expand Forum to Full Width