+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 31 to 44 of 44

Thread: Macro To Copy Specific Data Into A Separate Worksheet

  1. #31
    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

    Change
    For j = 3 to lrow
    to
     For j = 5 to lrow
    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]

  2. #32
    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

    Changed - however I get an error if a question is marked N/A - did not get this error on the example

  3. #33
    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

    Right click on the sheet where you need the validation and select "View Code" and input this code
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("I" & Target.Row).Value = "" Then
            MsgBox "Please enter score", vbCritical, "Enter Score:"
            Range("I" & Target.Row).Select
        End If
    End Sub
    However, i observed that you have grouped the radio buttons. I dont think this code will work properly in this case. Try ungrouping it and then it should work.
    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]

  4. #34
    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 error do you get?
    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]

  5. #35
    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 - will try to incorporate this.

    I get runtime error 13
    Type mismatch

  6. #36
    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 not getting any error. Can you try again please?
    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]

  7. #37
    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

    I'm still getting the same error on the attached example in post 28 - its only if you leave one/all question marked n/a

    Did not get this error on the example though

    Thanks

  8. #38
    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

    Ok got it. Since the last 2 rows dont need to be evaluated (they only contain titles), change your for statement to
     for j = 5 to lrow -2
    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]

  9. #39
    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. Got rid of error but the n/a mark is copying through now

  10. #40
    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

    Its just small small things that we ignore. Change this line
     For j = 5 To lrow - 2
                If Worksheets(i).Range("E" & j).Value <> "" And Worksheets(i).Range("D" & j).Value <> "Section Total" And _
                Worksheets(i).Range("I" & j).Value <= 3 And Worksheets(i).Range("X" & j+1).Value <= 2 Then
    to
     For j = 5 To lrow - 2
                If Worksheets(i).Range("E" & j).Value <> "" And Worksheets(i).Range("D" & j).Value <> "Section Total" And _
                Worksheets(i).Range("I" & j).Value <= 3 And Worksheets(i).Range("X" & j).Value <= 2 Then
    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. #41
    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

    Brilllll!! Thank-you sooo much!

  12. #42
    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

    Change this part of your code from
     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
    to
     With Worksheets("Action")
                       lastrow=.range("B" & rows.count).end(xlup).row
                        .Range("B" & lastrow).Value = Worksheets(i).Name
                        .Range("C" & lastrow).Value = Worksheets(i).Range("B" & j).Value
                        .Range("D" & lastrow).Value = Worksheets(i).Range("C" & j).Value
                        .Range("E" & lastrow).Value = Worksheets(i).Range("G" & j).Value
                        .Range("F" & lastrow).Value = Worksheets(i).Range("H" & j).Value
                    End With
    Also, at the top of your code, add another DIM statement - Dim lastrow as long
    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]

  13. #43
    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

    Again due to different headings in my original document and my lack of knowledge i'm unable to get this to work.
    Hope you could have a look for me.

    Regards
    Attached Files Attached Files

  14. #44
    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

    Sorry my bad. The previous code that i gave you. Add a "+1" to the lastrow. In other words, it should read as
      With Worksheets("Action")
                       lastrow=.range("B" & rows.count).end(xlup).row
                        .Range("B" & lastrow+1).Value = Worksheets(i).Name
                        .Range("C" & lastrow+1).Value = Worksheets(i).Range("B" & j).Value
                        .Range("D" & lastrow+1).Value = Worksheets(i).Range("C" & j).Value
                        .Range("E" & lastrow+1).Value = Worksheets(i).Range("G" & j).Value
                        .Range("F" & lastrow+1).Value = Worksheets(i).Range("H" & j).Value
                    End With
    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