maghari
02-20-2020, 05:18 AM
hello
i need help adjusting my code it calls data from sheet("data") to sheet ("sheet1")
Calling an accountant's registration, basic condition, registration number
I wrote the code and it works efficiently
But I want to add other conditions
If the account name is the same, whether a debtor(column j in sheet data) or a creditor(column k in sheet data) it is not repeated and the sum is collected when i search in sheet1 the range of search in sheet1 the range is( "g2")
i hope somebody help
Sub kid()
Dim Sh As Worksheet, ws As Worksheet, C As Range
Dim LR As Long, i As Long
Set ws = Sheet1: Set Sh = data2
ws.Range("a5:i1000").ClearContents
LR = Sh.Range("c" & Rows.Count).End(xlUp).Row
i = 4
For Each C In Sh.Range("c5:c" & LR)
If C.Value = ws.Range("g2").Value Then
i = i + 1
ws.Cells(i, "B") = C.Offset(0, 3)
ws.Cells(i, "C") = C.Offset(0, 2)
ws.Cells(i, "D") = C.Offset(0, 4)
ws.Cells(i, "E") = C.Offset(0, 5)
ws.Cells(i, "F") = C.Offset(0, 6)
ws.Cells(i, "G") = C.Offset(0, 7)
ws.Cells(i, "h") = C.Offset(0, 8)
ws.Cells(i, "i") = C.Offset(0, 9)
End If
Next
End Sub
by the way i have ever issue this subject in this forum but no replying any one
https://www.mrexcel.com/board/threads/adjusting-code-calling-data-in-worksheet.1124694/#post-5430447
i need help adjusting my code it calls data from sheet("data") to sheet ("sheet1")
Calling an accountant's registration, basic condition, registration number
I wrote the code and it works efficiently
But I want to add other conditions
If the account name is the same, whether a debtor(column j in sheet data) or a creditor(column k in sheet data) it is not repeated and the sum is collected when i search in sheet1 the range of search in sheet1 the range is( "g2")
i hope somebody help
Sub kid()
Dim Sh As Worksheet, ws As Worksheet, C As Range
Dim LR As Long, i As Long
Set ws = Sheet1: Set Sh = data2
ws.Range("a5:i1000").ClearContents
LR = Sh.Range("c" & Rows.Count).End(xlUp).Row
i = 4
For Each C In Sh.Range("c5:c" & LR)
If C.Value = ws.Range("g2").Value Then
i = i + 1
ws.Cells(i, "B") = C.Offset(0, 3)
ws.Cells(i, "C") = C.Offset(0, 2)
ws.Cells(i, "D") = C.Offset(0, 4)
ws.Cells(i, "E") = C.Offset(0, 5)
ws.Cells(i, "F") = C.Offset(0, 6)
ws.Cells(i, "G") = C.Offset(0, 7)
ws.Cells(i, "h") = C.Offset(0, 8)
ws.Cells(i, "i") = C.Offset(0, 9)
End If
Next
End Sub
by the way i have ever issue this subject in this forum but no replying any one
https://www.mrexcel.com/board/threads/adjusting-code-calling-data-in-worksheet.1124694/#post-5430447