Sir I got a code like below,but I want to sort out and copy each party's sum of sales, cash received, cheque received, discount given, goods return etc. in a new sheet w. Sample file attached. Can somebody give a solution? That is Total of Invoice amount, Total of Cash received, Total of Cash Transfer, Total of Discount given, Total of Credit note for Each party.Hi Jack
Use the following;
set sh = sheet1
Where Sheet1 is the sheet object number. You will never need to edit your sheet name again provided the sheet does not get deleted.
Take care
Smallman
Sir I got a code like below,but I want to sort out and copy each party's sum of sales, cash received, cheque received, discount given, goods return etc. in a new sheet w. Sample file attached. Can somebody give a solution? That is Total of Invoice amount, Total of Cash received, Total of Cash Transfer, Total of Discount given, Total of Credit note for Each party.Hi Jack ,
Try this :
Set sh = Sheets("Invoice-Cash-Cheque")
Narayan
Thank you SirHi ,
I am sorry but I will not be able to spare time for this for at least 2 days ; if you can wait till then , I can certainly do it ; if it is urgent , I hope someone else will come forward and help out.
Narayan
Option Explicit
Sub totBygrp()
Dim sh As Worksheet
Dim i As Integer
Set sh = Sheet3
Application.ScreenUpdating = False
For i = 2 To sh.Range("A" & Rows.Count).End(xlUp).Row
Sheet1.[b2] = sh.Range("A" & i)
Sheet1.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = sh.Range("A" & i)
Next i
Application.ScreenUpdating = True
End Sub
Sir I want all party name in one sheetHi Jack
This is pretty quick and dirty but is this what you were trying to do.
Code:Option Explicit Sub totBygrp() Dim sh As Worksheet Dim i As Integer Set sh = Sheet3 Application.ScreenUpdating = False For i = 2 To sh.Range("A" & Rows.Count).End(xlUp).Row Sheet1.[b2] = sh.Range("A" & i) Sheet1.Copy After:=Sheets(Sheets.Count) ActiveSheet.Name = sh.Range("A" & i) Next i Application.ScreenUpdating = True End Sub
File attached to show workings.
Smallman
Jack
I don't understand what you are trying to do. Post an example with an output page which clearly shows what you are looking for after the procedure is run.
Take care
Smallman
Jack
I don't understand what you are trying to do. Post an example with an output page which clearly shows what you are looking for after the procedure is run.
Take care
Smallman
Sir I have posted a macro which Total only Invoice, Cash and Cheque. Now here posted clearly in the uploaded sheet Output sheet what I required, so please look into this matter
Thanks and Regards
Hi Jack,
I am not working on your logic or code.. I just want to point out few things..
View attachment 1003
1. Referring to Sheet by Sheets Display Name
Set sh = sheets("Requirement")
Every sheet has unique Display Name, which is displayed in the Tab you can change. In above pic.. 3rd Sheet in the workbook (YELLOW).
2. Referring to Sheet by Sheets Code Name
Set sh = sheets99
Every sheet has unique Name, which you can change from Name Property .. 3rd Sheet in the workbook(PINK).
3. Referring to Sheet by Sheets Index Number
Set sh = Sheet(3)
An index number is a sequential number assigned to a sheet, based on the position of its sheet tab (counting from the left) among sheets of the same type .. You can't change it. 3rd Sheet in the workbook(BROWN).
1st check, which one in more trustworthy..
If your sheet's position changes randomly.. ignore referring sheet by Index Number..
If your Sheet's Display Name or Code Name is changes randomly use referring sheet by Index Number..
Its fully depends on the behavior of workbook, so decide and use any of the above code to
Edit sheet name in your macro..
i.e Set sh = Sheet(1) will refer to sheets("Database") which is also known as Sheet3
Hi Jack,
I am not working on your logic or code.. I just want to point out few things..
View attachment 1003
1. Referring to Sheet by Sheets Display Name
Set sh = sheets("Requirement")
Every sheet has unique Display Name, which is displayed in the Tab you can change. In above pic.. 3rd Sheet in the workbook (YELLOW).
2. Referring to Sheet by Sheets Code Name
Set sh = sheets99
Every sheet has unique Name, which you can change from Name Property .. 3rd Sheet in the workbook(PINK).
3. Referring to Sheet by Sheets Index Number
Set sh = Sheet(3)
An index number is a sequential number assigned to a sheet, based on the position of its sheet tab (counting from the left) among sheets of the same type .. You can't change it. 3rd Sheet in the workbook(BROWN).
1st check, which one in more trustworthy..
If your sheet's position changes randomly.. ignore referring sheet by Index Number..
If your Sheet's Display Name or Code Name is changes randomly use referring sheet by Index Number..
Its fully depends on the behavior of workbook, so decide and use any of the above code to
Edit sheet name in your macro..
i.e Set sh = Sheet(1) will refer to sheets("Database") which is also known as Sheet3
Sir Can you remove this post because still I did not receive any right solution.Hi ,
I am sorry but I will not be able to spare time for this for at least 2 days ; if you can wait till then , I can certainly do it ; if it is urgent , I hope someone else will come forward and help out.
Narayan
Sub OutputSheet()
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Output").Delete
On Error GoTo 0
Sheets.Add(, Sheets(Sheets.Count)).Name = "Output"
With Sheets("Output")
.Range("A1:I1") = Array("Party Name", "Amount", "Cash Received", "Cheque Received", "Sales Return", "Cash Transfer", "Goods Return", "Discount Given", "Cash T/F to Bank")
Nudata = Sheets("Database").Range("A2").End(xlDown).Row
Sheets("Database").Range("A2:A" & Nudata).Copy .Range("A2")
.Range("B2:B" & Nudata).Formula = "=SUMIFS('Invoice-Cash-Cheque'!D:D,'Invoice-Cash-Cheque'!$B:$B,$A2)"
.Range("C2:I" & Nudata).Formula = "=SUMIFS('Invoice-Cash-Cheque'!$E:$E,'Invoice-Cash-Cheque'!$B:$B,$A2,'Invoice-Cash-Cheque'!$C:$C,C$1)"
.Range("D2:D" & Nudata).Formula = "=SUMIFS('Invoice-Cash-Cheque'!$F:$F,'Invoice-Cash-Cheque'!$B:$B,$A2,'Invoice-Cash-Cheque'!$C:$C,D$1)"
With .Range("A1:I" & Nudata)
.Value = .Value
.Columns.AutoFit
.NumberFormat = "$ 0.00"
End With
End With
End Sub