Put the result of the calculation between 2 columns in a new works

M

Metin

Hi all,

I have a worksheet with 18 columns. Each column has a lot of data, and each
time I have various number of data. The number of data can be between 200 and
5000 in one column. The number of data in each column is always equal.The
data starts at row 2, because row 1 is always the title.
I want to subtract the data from column J with data from column F, and the
results I want to put in a new sheet, called "calculate data" in Column F.
Could somebody tell me how to do this with VB.

Thanx,
-Metin-
 
M

Metin

I have it already in simple formula. I need it for further calculations and
when I have new data I don't want to use the template of a previous file.
Very often the users forgot to delete the remaining data of the previous file.
In VBA I have already did the insert of new sheet and the insert of the
titles.

If you know how to do it in VBA, pls tell me.
 
B

Bob Phillips

Here is a VBA solution

Sub test()
Dim i As Long
Dim cLastRow As Long
Dim oWS As Worksheet

With Worksheets("Sheet1")
cLastRow = .Cells(.Rows.Count, "J").End(xlUp).Row
Set oWS = Worksheets.Add
oWS.Name = "calculate data"
oWS.Cells(1, "J").Value = .Cells(1, "J").Value
For i = 2 To cLastRow
oWS.Cells(i, "J").Value = .Cells(i, "J").Value - _
.Cells(i, "F").Value
Next i
End With

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top