Forum Discussion
Suma_shankar
Jun 06, 2020Copper Contributor
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...
- Jun 07, 2020Thanks 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
George Hepworth
Jun 06, 2020Iron Contributor
Suma_shankar Are you doing this in Excel or in Access?
If it's in Excel, you'll probably get better response if you post this in the appropriate Excel forum.
Suma_shankar
Jun 06, 2020Copper Contributor
Thanks for your suggestion.
- Logaraj SekarJun 06, 2020Iron Contributor
- Suma_shankarJun 07, 2020Copper ContributorDone it
- Logaraj SekarJun 07, 2020Iron ContributorOkay.. I saw that. But the code only write top 3 values. if you want change top any value or you should choose my code.