Code needs to be corrected

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello guys

I have this code running through four sheets. The code is running perfectly but for one small error due to which I am not able to import it to my software. In sheet F, cell F18 should be blank. Can someone please check and edit the code so that the cell F18 is blank.

As I am unaware how to post the workbook, I am posting 2 sheets for reference. The sheet “Z” is blank. The sheet original has the bank name in cell K1.

I have inserted a button in sheet F to run the code.

acxCode-correction.xlsm
ABCDEFGHIJKLMNOPQR
1RemarkDateVoucher TypeVoucher No.NarrationLedger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name
2Matched01-07-2021Receipt1011Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
3Matched01-07-2021Payment1012Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
4Matched02-07-2021Receipt1013Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
5Matched03-07-2021Payment1014Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
6Matched04-07-2021Payment1015Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
7Matched05-07-2021Receipt1016Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
8Matched09-07-2021Payment1017Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
9 00000
10 00000
11 
F
Cell Formulas
RangeFormula
A2:A11A2=IF(B2&C2&F2&G2&H2&I2="","",IF(OR(B2="",C2="",F2="",G2="",H2="",I2=""),"Debit/Credit Not Matching",IF(BG2=0,"Matched","Debit/Credit Not Matching")))


acxCode-correction.xlsm
ABCDEFG
1LineDateVch TypeVch No.ParticularsDebitCredit
23004-07-2021Payment1002January100.00
33606-07-2021Contra1003Cash1000.00
43706-07-2021Contra1004Cash2000.00
54411-07-2021Receipt1005Sunday1015.00
64511-07-2021Payment1006January100.00
74612-07-2021Receipt1007Sunday1015.00
84712-07-2021Payment1008January100.00
94814-07-2021Contra1009Cash2000.00
104914-07-2021Contra1010Cash1000.00
11
12101-07-2021Receipt1011Kotak Mahindra Bank4040.00
132Sunday1015.00
143Monday2025.00
154Tuesday1000.50
165Round Off0.50
17601-07-2021Payment1012Kotak Mahindra Bank1001.00
187January100.00
198February200.00
209March300.00
2110April400.00
2211Round Off1.00
231202-07-2021Receipt1013Kotak Mahindra Bank4040.00
2413Sunday1015.00
2514Monday2025.00
2615Tuesday1000.50
2716Round Off0.50
281803-07-2021Payment1014Kotak Mahindra Bank1001.00
2919January100.00
3020February200.00
3121March300.00
3222April400.00
3323Round Off1.00
342404-07-2021Payment1015Kotak Mahindra Bank1001.00
3525January100.00
3626February200.00
3727March300.00
3828April400.00
3929Round Off1.00
403105-07-2021Receipt1016Kotak Mahindra Bank4040.00
4132Sunday1015.00
4233Monday2025.00
4334Tuesday1000.50
4435Round Off0.50
453809-07-2021Payment1017Kotak Mahindra Bank1001.00
4639January100.00
4740February200.00
4841March300.00
4942April400.00
5043Round Off1.00
Bank
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Oops Sorry. I forgot to post the code.
Option Explicit

Sub Step4()
'single entries to copy below multiple entries

Sheets("Bank").Select
Range("A1").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Z").Select
Range("A2").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Columns("F:G").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight
Range("F2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=IF(RC[2]="""",RC[3],-RC[2])"
Range("G2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=-RC[-1]"
Range("F2:G2").Select
Selection.AutoFill Destination:=Range("F2:G21")
Range("F2:G21").Select
Range("F2:G2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("B2").Select

Dim sh As Worksheet
Dim NewName As String
Dim sh1 As Worksheet
Dim p As Variant
Dim pp As Variant
Dim x As Integer
Dim s()
Dim ss()
Application.ScreenUpdating = False
Application.CutCopyMode = False
Set sh = Sheets("Z")
Set sh1 = Sheets("F")
NewName = Sheets("Original").Range("K1")
s = Array(2, 3, 4, 5, 6, 7)
ss = Array(2, 3, 4, 8, 7, 9)
p = sh.Cells(Rows.Count, 1).End(3).Row
pp = sh1.Cells(Rows.Count, 3).End(3).Row + 1
For x = 0 To UBound(s)
sh.Range(sh.Cells(3, s(x)), sh.Cells(p, s(x))).Copy sh1.Cells(pp, ss(x))
Next x
sh1.Cells(pp, "f").Resize(p - 1) = NewName
Application.ScreenUpdating = True
Application.CutCopyMode = True
Sheets("F").Select
Range("B9:I19").Select
End Sub
 
Upvote 0
Hello guys

I have this code running through four sheets. The code is running perfectly but for one small error due to which I am not able to import it to my software. In sheet F, cell F18 should be blank. Can someone please check and edit the code so that the cell F18 is blank.

As I am unaware how to post the workbook, I am posting 2 sheets for reference. The sheet “Z” is blank. The sheet original has the bank name in cell K1.

I have inserted a button in sheet F to run the code.

acxCode-correction.xlsm
ABCDEFGHIJKLMNOPQR
1RemarkDateVoucher TypeVoucher No.NarrationLedger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name Dr(-), Cr(+) Ledger Name
2Matched01-07-2021Receipt1011Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
3Matched01-07-2021Payment1012Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
4Matched02-07-2021Receipt1013Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
5Matched03-07-2021Payment1014Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
6Matched04-07-2021Payment1015Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
7Matched05-07-2021Receipt1016Kotak Mahindra Bank-4040Sunday1015Monday2025Tuesday1000.5Round Off-0.5
8Matched09-07-2021Payment1017Kotak Mahindra Bank1001January-100February-200March-300April-400Round Off-1
9 00000
10 00000
11 
F
Cell Formulas
RangeFormula
A2:A11A2=IF(B2&C2&F2&G2&H2&I2="","",IF(OR(B2="",C2="",F2="",G2="",H2="",I2=""),"Debit/Credit Not Matching",IF(BG2=0,"Matched","Debit/Credit Not Matching")))


acxCode-correction.xlsm
ABCDEFG
1LineDateVch TypeVch No.ParticularsDebitCredit
23004-07-2021Payment1002January100.00
33606-07-2021Contra1003Cash1000.00
43706-07-2021Contra1004Cash2000.00
54411-07-2021Receipt1005Sunday1015.00
64511-07-2021Payment1006January100.00
74612-07-2021Receipt1007Sunday1015.00
84712-07-2021Payment1008January100.00
94814-07-2021Contra1009Cash2000.00
104914-07-2021Contra1010Cash1000.00
11
12101-07-2021Receipt1011Kotak Mahindra Bank4040.00
132Sunday1015.00
143Monday2025.00
154Tuesday1000.50
165Round Off0.50
17601-07-2021Payment1012Kotak Mahindra Bank1001.00
187January100.00
198February200.00
209March300.00
2110April400.00
2211Round Off1.00
231202-07-2021Receipt1013Kotak Mahindra Bank4040.00
2413Sunday1015.00
2514Monday2025.00
2615Tuesday1000.50
2716Round Off0.50
281803-07-2021Payment1014Kotak Mahindra Bank1001.00
2919January100.00
3020February200.00
3121March300.00
3222April400.00
3323Round Off1.00
342404-07-2021Payment1015Kotak Mahindra Bank1001.00
3525January100.00
3626February200.00
3727March300.00
3828April400.00
3929Round Off1.00
403105-07-2021Receipt1016Kotak Mahindra Bank4040.00
4132Sunday1015.00
4233Monday2025.00
4334Tuesday1000.50
4435Round Off0.50
453809-07-2021Payment1017Kotak Mahindra Bank1001.00
4639January100.00
4740February200.00
4841March300.00
4942April400.00
5043Round Off1.00
Bank
Problem is solved.
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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