can I do same task in ever sheet of workbook.

Status
Not open for further replies.

ganu learner

New Member
Joined
Dec 31, 2019
Messages
47
Office Version
  1. 2013
Platform
  1. Windows
Res all Genius
Please do for me I am very thankful to you for make a dream script for me
At present I do my task again and again so that I waste too much time to do this
firstly I create new sheet from my master sheet according to row manually and rename my new sheet according to column A .
Than I paste my vba script for all my new sheets . In that process I waste my most of time .
So please make a new script for me and merge my currently running script with it


This is dynamically updated file so data of every row is updated by RTD SERVER.


In attached file I have total 9 rows ( my every new file with dynamic Row) . First row is header and from Row2 to Row 9 are my data row.


1.create new sheet for every Row ( from row2 to row 9) all my new sheets first row is common
example newsheet 1 = row 1 and row 2
new sheet 2 = row 1 and row 3...........................................................
new sheet 8 = row 1 and row 9

2. after create new sheets my main task is here. At present I paste my vba script to all new sheets manually.




currently I use below script for all of my new sheets.

Private Sub Worksheet_Calculate()
Dim capturerow As Long, currow As Long, col As String
On Error GoTo handerror

Application.EnableEvents = False
capturerow = 2
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 = "E"
ElseIf Cells(currow, "B") < Cells(currow + 1, "B") Then
col = "F"
Else
col = "G"
End If
Cells(currow, col) = Cells(currow + 1, "C") - Cells(currow, "C")
End If
Range("E4").Value = WorksheetFunction.Sum(Range("E5:E" & currow))
Range("F4").Value = WorksheetFunction.Sum(Range("F5:F" & currow))
Range("G4").Value = WorksheetFunction.Sum(Range("G5:G" & currow))
handerror:
Application.EnableEvents = True
End Sub
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Status
Not open for further replies.

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top