• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

chatgpt unable to help

Ateeb Ali

I have attached a file and a code, i made a button "copy data"
this code help me copying data from sheet: Outward GP Summary to sheet: Edit Form
Challenge I am getting that if sheet Outward GP Summary column H which to be matched with Sheet: Edit Form Range O6
SOME UNWANTED ENtries are also fetching, for example, you can try number: 43717 which to be fetch just one line but it is fetching multiple which is wrong
I appreciate urgent help on this matter

Sub CopyValuesBasedOnConditionsAD()
Dim ws As Worksheet
Dim summarySheet As Worksheet
Dim lookupValue As Variant
Dim lookupRange As Range
Dim matchCell As Range
Dim destRange As Range
Application.ScreenUpdating = False

' Set the active sheet
Set ws = ActiveSheet

' Set the summary sheet
Set summarySheet = ThisWorkbook.Sheets("Outward GP Summary")

' Set the lookup value from active sheet cell o6
lookupValue = ws.Range("o6").Value

' Set the range in the summary sheet's column H
Set lookupRange = summarySheet.Range("H:H")

' Set the destination range in the active sheet
Set destRange = ws.Range("B14:L33")

' Find the match in the lookup range
Set matchCell = lookupRange.Find(lookupValue, LookIn:=xlValues)

' Check if a match is found
If Not matchCell Is Nothing Then
' Copy values based on conditions
ws.Range("F1").Value = summarySheet.Cells(matchCell.row, 1).Value ' Added condition for F1
ws.Range("G2").Value = summarySheet.Cells(matchCell.row, 2).Value
ws.Range("G3").Value = summarySheet.Cells(matchCell.row, 3).Value
ws.Range("G4").Value = summarySheet.Cells(matchCell.row, 4).Value
ws.Range("B4").Value = summarySheet.Cells(matchCell.row, 5).Value
ws.Range("B5").Value = summarySheet.Cells(matchCell.row, 6).Value
ws.Range("C8").Value = summarySheet.Cells(matchCell.row, 9).Value
ws.Range("C9").Value = summarySheet.Cells(matchCell.row, 10).Value
ws.Range("C10").Value = summarySheet.Cells(matchCell.row, 11).Value
ws.Range("C11").Value = summarySheet.Cells(matchCell.row, 12).Value
ws.Range("C12").Value = summarySheet.Cells(matchCell.row, 13).Value
ws.Range("I8").Value = summarySheet.Cells(matchCell.row, 15).Value
ws.Range("I9").Value = summarySheet.Cells(matchCell.row, 16).Value
ws.Range("I10").Value = summarySheet.Cells(matchCell.row, 17).Value

' Copy values from columns S, T, U, X, Y, Z, N, AA, AB, AC to the range B14:L33 on the active sheet
destRange.Columns(1).Value = summarySheet.Cells(matchCell.row, 19).Resize(20, 1).Value ' Column S
destRange.Columns(2).Value = summarySheet.Cells(matchCell.row, 20).Resize(20, 1).Value ' Column T
destRange.Columns(3).Value = summarySheet.Cells(matchCell.row, 21).Resize(20, 1).Value ' Column U
destRange.Columns(6).Value = summarySheet.Cells(matchCell.row, 24).Resize(20, 1).Value ' Column X
destRange.Columns(7).Value = summarySheet.Cells(matchCell.row, 25).Resize(20, 1).Value ' Column Y
destRange.Columns(8).Value = summarySheet.Cells(matchCell.row, 26).Resize(20, 1).Value ' Column Z
destRange.Columns(9).Value = summarySheet.Cells(matchCell.row, 27).Resize(20, 1).Value ' Column AA
destRange.Columns(10).Value = summarySheet.Cells(matchCell.row, 28).Resize(20, 1).Value ' Column AB
destRange.Columns(11).Value = summarySheet.Cells(matchCell.row, 29).Resize(20, 1).Value ' Column AC

' Add condition to mark "C" only if column H matches the lookup value
If summarySheet.Cells(matchCell.row, 8).Value = lookupValue Then
summarySheet.Cells(matchCell.row, 30).Value = "C" ' Assuming Column AD is column 30
End If

' Handle case where no match is found
MsgBox "No match found for the value in o6.", vbExclamation
End If
Application.ScreenUpdating = True
End Sub

Ateeb Ali

As written in
  • Use Relevant words in the Title and in the tag Box, This will aid future searches.
  • Never title your posts as "Urgent", "Priority" "Immediate". It may be Important to you, but not for rest of the members here. These words will be moderated out.
That's chatgpt code? Yuk.
Made mininal changes to the code - I haven't got time to make it more streamlined/elegant. See attached.


  • chandoo55516.xlsb
    29 KB · Views: 5