Forum Discussion

Suma_shankar's avatar
Suma_shankar
Copper Contributor
Jun 06, 2020
Solved

Need help with excel vba

I have two sheets -sheet1 and sheet2, sheet 2 need to fetch the larger number of sheet1 from column b and also column e cell value for the first time. This process has to repeat to paste in new next l...
  • Suma_shankar's avatar
    Suma_shankar
    Jun 07, 2020
    Thanks for your reply.
    Ur code is working fine sir. I just modified ur code by adding to find two more larger numbers from the same range and pasting it into another sheet.
    Sub oi()
    Dim a, c, e, g As Long
    Dim d, b, f, h As Range
    With Worksheets("NIFTY").Range("B11:B96")
    c = Application.WorksheetFunction.Large(.Cells, 1)
    Set b = .Find(c).Offset(0, 4).Cells
    e = Application.WorksheetFunction.Large(.Cells, 2)
    Set f = .Find(e).Offset(0, 4).Cells
    g = Application.WorksheetFunction.Large(.Cells, 3)
    Set h = .Find(g).Offset(0, 4).Cells
    End With

    Set d = Application.Sheets("Sheet2").UsedRange
    a = d.Cells.Rows.Count + d.Row
    Worksheets("Sheet2").Activate
    Worksheets("Sheet2").Cells(a, 2).Select
    Selection.Value2 = b

    Worksheets("Sheet2").Cells(a, 3).Select
    Selection.Value2 = f

    Worksheets("Sheet2").Cells(a, 4).Select
    Selection.Value2 = h
    End Sub

Resources