ganu learner
New Member
- Joined
- Dec 31, 2019
- Messages
- 47
- Office Version
- 2013
- Platform
- Windows
res sir please make a common script for all new sheet in workbook. My two script is below here
1. rename my workbook NiftyEnergy MW to "mainsheet"
2. after create new sheet form main sheet run below script for all new sheet not for main sheet only out put of new sheet shown in main sheet .
3. output of below script also show in main sheet of same Row and column
MY excel file BBCODE is here
1. rename my workbook NiftyEnergy MW to "mainsheet"
VBA Code:
Sub ganulearner()
Dim Hdr As Variant
Dim Cl As Range
With Sheets("NiftyEnergy MW")
Hdr = .Range("1:1").Value
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
Sheets.Add(, Sheets(.Index)).Name = Cl.Value
Range("1:1").Value = Hdr
Cl.EntireRow.Copy Range("A2")
Next Cl
End With
End Sub
VBA Code:
Private Sub Worksheet_Calculate()
Dim capturerow As Long, currow As Long, col As String
On Error GoTo handerror
Application.EnableEvents = False
capturerow = 2
If Range("T1") = "" Then
Range("c:h").EntireColumn.Insert
endif
currow = Range("A65536").End(xlUp).Row
If currow < 5 Then currow = 5
Cells(currow + 1, 1) = Cells(capturerow, 1)
Cells(currow + 1, 2) = Cells(capturerow, 2)
Cells(currow + 1, 3) = Cells(capturerow, 3)
Cells(currow + 1, 4) = Cells(capturerow, 4)
If currow > 5 Then
If Cells(currow, "B") > Cells(currow + 1, "B") Then
col = "F"
ElseIf Cells(currow, "B") < Cells(currow + 1, "B") Then
col = "G"
Else
col = "H"
End If
Cells(currow, col) = Cells(currow + 1, "C") - Cells(currow, "C")
End If
Range("F2").Value = WorksheetFunction.Sum(Range("E5:E" & currow))
Range("G2").Value = WorksheetFunction.Sum(Range("F5:F" & currow))
Range("H2").Value = WorksheetFunction.Sum(Range("G5:G" & currow))
Range("E2").value = WorksheetFunction.Sum(Range("E5:E" & currow)) - WorksheetFunction.Sum(Range("F5:F" & currow))
handerror:
Application.EnableEvents = True
End Sub
VBA Code:
Range("F2").Value = WorksheetFunction.Sum(Range("E5:E" & currow))
Range("G2").Value = WorksheetFunction.Sum(Range("F5:F" & currow))
Range("H2").Value = WorksheetFunction.Sum(Range("G5:G" & currow))
Range("E2").value = WorksheetFunction.Sum(Range("E5:E" & currow)) - WorksheetFunction.Sum(Range("F5:F" & currow))[/COLOR]
MY excel file BBCODE is here
Cell Formulas | ||
---|---|---|
Range | Formula | |
A2 | A2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "TradingSymbol") |
B2 | B2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Last") |
C2 | C2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "BidSize") |
D2 | D2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Bid") |
E2 | E2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Ask") |
F2 | F2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "AskSize") |
G2 | G2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "LTQ") |
H2 | H2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Open") |
I2 | I2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "High") |
J2 | J2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Low") |
K2 | K2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "PrevClose") |
L2 | L2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Volume") |
M2 | M2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "OpenInterest") |
N2 | N2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "AverageTradePrice") |
O2 | O2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "TotalBidQty") |
P2 | P2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "TotalAskQty") |
Q2 | Q2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "Exchange") |
R2 | R2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "lastTradeTime") |
S2 | S2 | =RTD("pi.rtdserver", ,"NSE_RELIANCE-EQ", "lastUpdateTime") |
A3 | A3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "TradingSymbol") |
B3 | B3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Last") |
C3 | C3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "BidSize") |
D3 | D3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Bid") |
E3 | E3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Ask") |
F3 | F3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "AskSize") |
G3 | G3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "LTQ") |
H3 | H3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Open") |
I3 | I3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "High") |
J3 | J3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Low") |
K3 | K3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "PrevClose") |
L3 | L3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Volume") |
M3 | M3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "OpenInterest") |
N3 | N3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "AverageTradePrice") |
O3 | O3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "TotalBidQty") |
P3 | P3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "TotalAskQty") |
Q3 | Q3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "Exchange") |
R3 | R3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "lastTradeTime") |
S3 | S3 | =RTD("pi.rtdserver", ,"NSE_BPCL-EQ", "lastUpdateTime") |
A4 | A4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "TradingSymbol") |
B4 | B4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Last") |
C4 | C4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "BidSize") |
D4 | D4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Bid") |
E4 | E4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Ask") |
F4 | F4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "AskSize") |
G4 | G4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "LTQ") |
H4 | H4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Open") |
I4 | I4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "High") |
J4 | J4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Low") |
K4 | K4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "PrevClose") |
L4 | L4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Volume") |
M4 | M4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "OpenInterest") |
N4 | N4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "AverageTradePrice") |
O4 | O4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "TotalBidQty") |
P4 | P4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "TotalAskQty") |
Q4 | Q4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "Exchange") |
R4 | R4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "lastTradeTime") |
S4 | S4 | =RTD("pi.rtdserver", ,"NSE_HINDPETRO-EQ", "lastUpdateTime") |
A5 | A5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "TradingSymbol") |
B5 | B5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Last") |
C5 | C5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "BidSize") |
D5 | D5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Bid") |
E5 | E5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Ask") |
F5 | F5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "AskSize") |
G5 | G5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "LTQ") |
H5 | H5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Open") |
I5 | I5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "High") |
J5 | J5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Low") |
K5 | K5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "PrevClose") |
L5 | L5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Volume") |
M5 | M5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "OpenInterest") |
N5 | N5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "AverageTradePrice") |
O5 | O5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "TotalBidQty") |
P5 | P5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "TotalAskQty") |
Q5 | Q5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "Exchange") |
R5 | R5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "lastTradeTime") |
S5 | S5 | =RTD("pi.rtdserver", ,"NSE_POWERGRID-EQ", "lastUpdateTime") |
A6 | A6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "TradingSymbol") |
B6 | B6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Last") |
C6 | C6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "BidSize") |
D6 | D6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Bid") |
E6 | E6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Ask") |
F6 | F6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "AskSize") |
G6 | G6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "LTQ") |
H6 | H6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Open") |
I6 | I6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "High") |
J6 | J6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Low") |
K6 | K6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "PrevClose") |
L6 | L6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Volume") |
M6 | M6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "OpenInterest") |
N6 | N6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "AverageTradePrice") |
O6 | O6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "TotalBidQty") |
P6 | P6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "TotalAskQty") |
Q6 | Q6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "Exchange") |
R6 | R6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "lastTradeTime") |
S6 | S6 | =RTD("pi.rtdserver", ,"NSE_ONGC-EQ", "lastUpdateTime") |
A7 | A7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "TradingSymbol") |
B7 | B7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Last") |
C7 | C7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "BidSize") |
D7 | D7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Bid") |
E7 | E7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Ask") |
F7 | F7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "AskSize") |
G7 | G7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "LTQ") |
H7 | H7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Open") |
I7 | I7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "High") |
J7 | J7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Low") |
K7 | K7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "PrevClose") |
L7 | L7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Volume") |
M7 | M7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "OpenInterest") |
N7 | N7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "AverageTradePrice") |
O7 | O7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "TotalBidQty") |
P7 | P7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "TotalAskQty") |
Q7 | Q7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "Exchange") |
R7 | R7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "lastTradeTime") |
S7 | S7 | =RTD("pi.rtdserver", ,"NSE_IOC-EQ", "lastUpdateTime") |
A8 | A8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "TradingSymbol") |
B8 | B8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Last") |
C8 | C8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "BidSize") |
D8 | D8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Bid") |
E8 | E8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Ask") |
F8 | F8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "AskSize") |
G8 | G8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "LTQ") |
H8 | H8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Open") |
I8 | I8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "High") |
J8 | J8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Low") |
K8 | K8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "PrevClose") |
L8 | L8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Volume") |
M8 | M8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "OpenInterest") |
N8 | N8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "AverageTradePrice") |
O8 | O8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "TotalBidQty") |
P8 | P8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "TotalAskQty") |
Q8 | Q8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "Exchange") |
R8 | R8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "lastTradeTime") |
S8 | S8 | =RTD("pi.rtdserver", ,"NSE_NTPC-EQ", "lastUpdateTime") |
A9 | A9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "TradingSymbol") |
B9 | B9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Last") |
C9 | C9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "BidSize") |
D9 | D9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Bid") |
E9 | E9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Ask") |
F9 | F9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "AskSize") |
G9 | G9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "LTQ") |
H9 | H9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Open") |
I9 | I9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "High") |
J9 | J9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Low") |
K9 | K9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "PrevClose") |
L9 | L9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Volume") |
M9 | M9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "OpenInterest") |
N9 | N9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "AverageTradePrice") |
O9 | O9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "TotalBidQty") |
P9 | P9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "TotalAskQty") |
Q9 | Q9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "Exchange") |
R9 | R9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "lastTradeTime") |
S9 | S9 | =RTD("pi.rtdserver", ,"NSE_TATAPOWER-EQ", "lastUpdateTime") |