summ gg

  • Thread starter Thread starter sal21
  • Start date Start date
S

sal21

These sheet contain a simple planning of vacation.
My problem is to summ from every column with GG refered for ever
NOMINATIVO and insert the result after the related NOMINATIVO in to
parentesis

example: UBALDI GENNARO (13)

Note: The column GG are in txt formt and it obbligatory must remain i
this forma

Attachment filename: addition_colum_gg.zip
Download attachment: http://www.excelforum.com/attachment.php?postid=62726
 
Hi, Sal!

1. Open Workbook file.
2. Alt+F11
3. Double-click Worksheet.
4. Paste code:

Option Explicit

Sub SumItUp()

Dim x As Long
Dim y As Long
Dim LastRow As Long
Dim LastColumn As Long
Dim LeftPart As Long
Dim RightPart As Long
Dim MyTotal As Long

Application.ScreenUpdating = False

LastRow = Range("A6556").End(xlUp).Row
LastColumn = Range("IV4").End(xlToLeft).Column
On Error Resume Next
For x = 5 To LastRow
For y = 9 To LastColumn Step 4
LeftPart = Left(Cells(x, y).Text, _
Application.WorksheetFunction.Find(",", Cells(x, y).Text, 1) - 1)

RightPart = Right(Cells(x, y).Text, Len(Cells(x, y).Text) _
- Application.WorksheetFunction.Find(",", Cells(x, y).Text, 1))

MyTotal = MyTotal + LeftPart + RightPart
LeftPart = 0
RightPart = 0
Next y
Range("C" & x).Value = Range("C" & x).Text & " (" & MyTotal & ")"
MyTotal = 0
Application.StatusBar = x & " of " & LastRow
Next x

End Sub

________________________

**** Hope it helps! ****

~Dreamboat
www.VBAExpress.com/forum
************************
 
Anne said:
*Hi, Sal!

1. Open Workbook file.
2. Alt+F11
3. Double-click Worksheet.
4. Paste code:

Option Explicit

Sub SumItUp()

Dim x As Long
Dim y As Long
Dim LastRow As Long
Dim LastColumn As Long
Dim LeftPart As Long
Dim RightPart As Long
Dim MyTotal As Long

Application.ScreenUpdating = False

LastRow = Range("A6556").End(xlUp).Row
LastColumn = Range("IV4").End(xlToLeft).Column
On Error Resume Next
For x = 5 To LastRow
For y = 9 To LastColumn Step 4
LeftPart = Left(Cells(x, y).Text, _
Application.WorksheetFunction.Find(",", Cells(x, y).Text, 1) - 1)

RightPart = Right(Cells(x, y).Text, Len(Cells(x, y).Text) _
- Application.WorksheetFunction.Find(",", Cells(x, y).Text, 1))

MyTotal = MyTotal + LeftPart + RightPart
LeftPart = 0
RightPart = 0
Next y
Range("C" & x).Value = Range("C" & x).Text & " (" & MyTotal & ")"
MyTotal = 0
Application.StatusBar = x & " of " & LastRow
Next x

End Sub

________________________

**** Hope it helps! ****

~Dreamboat
www.VBAExpress.com/forum
************************
But is possible to alling this total for every NOMINATIVO, fo
example see my txt file

i have another a dubt, if you see BOTTA LAURA (line 26) the resul
after the macro is 16 and not 11,5
This line contain a alph day 0,5 in yor macro this number i
considearted 5

Attachment filename: alling.txt
Download attachment: http://www.excelforum.com/attachment.php?postid=62738
 
Back
Top