adjusting code calling data in worksheet

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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

VBA Code:
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
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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