+ Reply to Thread
Results 1 to 7 of 7

write to 2 sheets from userform

  1. #1
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    write to 2 sheets from userform

    hi
    I was given the code below which works for "sheet1",but when adapted it to write to sheet repairs as well, nothing writes to sheet "repairs",
    have tried different codes that works writing to 1 sheet , but am having trouble writing to both sheets from a macro,i know it can be done
    any help /pointers please
    cheers colin

    Please Login or Register  to view this content.
    Last edited by cfinch100; 02-20-2014 at 12:25 AM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: write to 2 sheets from userform

    This seems to be only part of your macro though.
    One thing I can say from a first look is that you don't want to change the assigment of "ws" in the middle of a "With" statement. Never.

    Do you only want to write on sheet "Repairs" or you also need to find where the combobox1 value is located on that sheet too? It can change lots of thing.

    It would be a good thing to attached a sample workbook so we can work out your macro. In the air like this, it is hard to be very specific.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: write to 2 sheets from userform

    hi
    sorry for late reply thanks for looking at it,have loaded program,it is userformservice when id is entered from combobox and date scrapped is entered ,copies to sheet1 where con format highlights and scrapped is entered ,also the id number is deleted and then transferred to different column so can not be selected through frmissue,data on formservice should also go to sheet repairs which it does not all other things work ok,i know its something ive added but can not see why it would not work
    hope this explains
    cheers colin
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: write to 2 sheets from userform

    Colin

    You shouldn't try and send the data to both sheets at the same time, use separate code for each sheet.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: write to 2 sheets from userform

    hi norie

    have just amended code and it now sends to both sheets,can you tell me why I should use separate code when this seems to work for now,thought you could
    thanks colin
    Please Login or Register  to view this content.

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: write to 2 sheets from userform

    This macro structure should work:
    Please Login or Register  to view this content.
    Remark that I created a second worksheet variable so you use it to address sheet REPAIRS.
    With the indentation, it is easier to see where a statement (IF - WITH - ...) starts and ends.
    You're not actually using a separated code to write on both sheet, you are just doing it one after the other.
    With a structured code, it's always easier to follow the process and see if something is wrong.

  7. #7
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: write to 2 sheets from userform

    hi p24leclerc
    many thanks for that works just how should do,had sort of done myself but yours is structured better
    cheers for pointers and code change
    colin

+ 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] Write value to userform parent
    By rybussell in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-07-2023, 01:03 PM
  2. Can't get VBA Userform (mac) to write data to worksheets
    By fickalli in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2012, 02:00 PM
  3. Write to Spreadsheet with Userform/Message Box On
    By arora in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2009, 06:23 AM
  4. Write to Columns from userform
    By Reidm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2008, 07:41 AM
  5. [SOLVED] write to external workbook from userform
    By nycdon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2005, 01:36 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