so what I'm trying to do right now is take a range (lets say C:C), go through all the cells with value and paste them in another spreadsheet. My target is to copy a variable value (because I don't know how many values I would have in C:C) and paste it on another sheet, so that I can have a new range with all the values (were there are no repeated values). My problem right now is that I don't know how to code the If statement (for variable values). If any one can help me I will be thankful. This is what I have to this point:
Sub Test_1()
' Go through each cells in the range
Dim rg As Range
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Data")
Set pasteSheet = Worksheets("Data_storage")
For Each rg In Worksheets("Data").Range("C:C")
If rg.Value = "Client 1" Then 'Instead of "Client 1" should be a variable value because "Client 1" will be a repetead value in C:C
copySheet.Range("C2").Copy 'Starting the counter in C2
pasteSheet.cells(Row.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValue
End If
Next
End Sub
Aucun commentaire:
Enregistrer un commentaire