locked
I need a output in VBA RRS feed

  • Question

  • Hi I need output as in sheet2 when I click  on the button2 in sheet1


    Tuesday, May 8, 2012 3:01 PM

All replies

  • Your logic is not consistent. Why is "Male" not in the same column as "Year1", while "Female" is? Why is "Issue Age" on the same row as "Year1"?  Why is "Year" not used? Why is "Gender" not used?

    HTH, Bernie

    Tuesday, May 8, 2012 5:18 PM
  • yes, "Male" can come in "year1" column
    Tuesday, May 8, 2012 5:26 PM
  • Fine to have more details, but...

    Sub transfer()
    Dim wks As Worksheet, wks_new As Worksheet, x&
    Set wks = ActiveSheet
    Set wks_new = Sheets.Add
    With wks_new
        .Range("a2") = wks.Range("b7")
        .Range("b1") = wks.Range("c2")
        .Range("e1") = wks.Range("c3")
        For x = 0 To 2
            .Range("b2").Offset(, x) = wks.Cells(4 + x, "c")
            .Range("e2").Offset(, x) = wks.Cells(4 + x, "c")
        Next x
    End With
    End Sub
    
    Sub transfer_with_format()
    Dim wks As Worksheet, wks_new As Worksheet, x&
    Set wks = ActiveSheet
    Set wks_new = Sheets.Add
    With wks_new
        wks.Range("b7").Copy .Range("a2")
        wks.Range("c2").Copy .Range("b1")
        wks.Range("c3").Copy .Range("e1")
        For x = 0 To 2
            wks.Cells(4 + x, "c").Copy .Range("b2").Offset(, x)
            wks.Cells(4 + x, "c").Copy .Range("e2").Offset(, x)
        Next x
    End With
    End Sub


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Tuesday, May 8, 2012 6:53 PM
    Answerer
  • If I have Level number varing i.e 1,2,3,4,5.. considering as 'N'. then I have the first factor as N-1 i.e here is 2 Male and female.

    Male                             female

    year1  year2 year3+    year1  year2 year3+

    similarly if I have  factor as band1, band2 band3. I need to implement as

    band1                           band2                               band3

    year1  year2 year3+    year1  year2 year3+           year1  year2 year3+

    Wednesday, May 9, 2012 4:43 AM