+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 15 of 44

Thread: Macro To Copy Specific Data Into A Separate Worksheet

  1. #1
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Macro To Copy Specific Data Into A Separate Worksheet

    Hi

    I have the following worksheets:
    - SECTION 1 - This worksheet acts like a questionnaire
    - Action Plan

    I would like the action plan to pick up any questions scored from 0-3 (ignoring any questions marked 'N/A'), which will then allow the user to input any actions in the 'grey' coloured cells etc. - see example

    I do have further sections/questionnaire on separate worksheets and I would like macro to do the same - after finding the blank row in the action list.

    I’m too good with my coding and hope someone can help or at least start me off – Many thanks!
    Attached Files Attached Files
    Last edited by sgp; 01-30-2012 at 05:59 AM.

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    How would the other sheets be named in your workbook? I need to know this so i can code it accordingly.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Hi..Other worksheets would be named as:

    -Section 2
    -Section 3

    This would do for now, thanks for responding!

  4. #4
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Any ideas??

  5. #5
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Use this code -
    Option Explicit
    Dim i As Long
    Dim j As Long
    Dim lrow As Long
    
    Sub cons_data()
    
    For i = 1 To Worksheets.Count
        If Worksheets(i).Name Like "Section*" Then
            lrow = Worksheets(i).Range("B" & Rows.Count).End(xlUp).Row
            For j = 3 To lrow
                If Worksheets(i).Range("C" & j).Value <> "" And Worksheets(i).Range("B" & j).Value <> "Section Total" And _
                Worksheets(i).Range("G" & j).Value <= 3 Then
                    With Worksheets("Action")
                        .Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Worksheets(i).Name
                        .Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = Worksheets(i).Range("B" & j).Value
                        .Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value = Worksheets(i).Range("C" & j).Value
                        .Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value = Worksheets(i).Range("G" & j).Value
                        .Range("F" & Rows.Count).End(xlUp).Offset(1, 0).Value = Worksheets(i).Range("H" & j).Value
                    End With
                End If
            Next j
        End If
    Next i
    
    End Sub
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #6
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Thanks that works great!! The only thing is that if a question is marked N/A the score should not go through - is this possible??

    Also, I don't quite understand the code but I think it will take the same range for each worksheet (Section 1, Section 2 etc) - the range could be different and there may be more worksheets with different worksheet names other than 'Section X' - is there a way of saying changing this in the code so it only takes the current worksheet name and the current range with worksheet 'Action'?

    Really appreciate your support!!! Thanks!

  7. #7
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    What do you mean by range could be different? Are there chances of the columns changing?
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    As in the number of questions are different on each section

  9. #9
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Columns will remain the same, thanks.

  10. #10
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Actually the macro is designed to take in how many ever questions there are. So even if it varies from sheet to sheet, it will still include them. Will provide you an updated code regarding the other changes you have suggested, shortly.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  11. #11
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Great that seems perfect!!

  12. #12
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Hi Arlette,

    It would be very useful if there could also be some validation to the scoring where a score is required to questions marked as either YES or NO and then the relevant information is transferred across...I think this will solve all my problems!

    Thanks.

  13. #13
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Do u want the validation as part of the code or will you be inputting it manually?
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  14. #14
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    Not quiet sure what the difference would be or what would be easier but I was initially thinking as part of a code.

    Regards.

  15. #15
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,396

    Re: Macro To Copy Specific Data Into A Separate Worksheet

    I am a little stuck with the option boxes. Will research and revert to you shortly.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0