M
Monomeeth
Hello
I have been using this code for about a year now, adapting it to suit
different workbooks and situations. However, I want to try and make it a
little more foolproof so that I can share it with other staff in our
organisation.
The code is as follows:
Sub RespondedToForm()
' Macro created to compare User IDs between the "Sent the Form"
' worksheet (on which this macro is run) and the "Responded to Form" worksheet
Dim c As Range
Dim findC As Variant
For Each c In ActiveSheet.Range("E2:E158")
If Not c Is Nothing Then
Set findC = Worksheets("Responded to form").Cells _
.Find(c.Value, LookIn:=xlValues)
If Not findC Is Nothing Then
ActiveSheet.Range("Q" & c.Row).Cells.Value = "Yes"
End If
End If
Next
End Sub
As you can see, this macro will check to see whether a User Id appearing in
the active sheet range E2 to E158 also appears in the "Responded to Form"
worksheet and if so, it places the text "Yes" in the corresponding row cell
at Column Q of the active worksheet.
I have always changed the ranges, worksheet names and text within the code
to suit my needs. However, I now want to be able to get other staff to use
this macro without the need for them to have to play with the code.
Ideally, I would like to design a user form that asks the user to specify
the: (i) worksheets being compared, (ii) ranges to compare, (iii) column in
which the text is to be added, (iv) actual text to be added.
I did try using a Do Until Loop with the IsEmpty command, but ran into
problems.
I'm no expert with VBA, but I know enough to be dangerous. I can also design
the user form, but getting the coding right is where I'm having problems.
However, I would be happy to consider other suggestions if this could be done
without the need of a user form, as I am unsure how transferable the user
form would be from one workbook to another when staff needed to use the macro
in different workbooks.
Hope this makes sense!
Joe.
I have been using this code for about a year now, adapting it to suit
different workbooks and situations. However, I want to try and make it a
little more foolproof so that I can share it with other staff in our
organisation.
The code is as follows:
Sub RespondedToForm()
' Macro created to compare User IDs between the "Sent the Form"
' worksheet (on which this macro is run) and the "Responded to Form" worksheet
Dim c As Range
Dim findC As Variant
For Each c In ActiveSheet.Range("E2:E158")
If Not c Is Nothing Then
Set findC = Worksheets("Responded to form").Cells _
.Find(c.Value, LookIn:=xlValues)
If Not findC Is Nothing Then
ActiveSheet.Range("Q" & c.Row).Cells.Value = "Yes"
End If
End If
Next
End Sub
As you can see, this macro will check to see whether a User Id appearing in
the active sheet range E2 to E158 also appears in the "Responded to Form"
worksheet and if so, it places the text "Yes" in the corresponding row cell
at Column Q of the active worksheet.
I have always changed the ranges, worksheet names and text within the code
to suit my needs. However, I now want to be able to get other staff to use
this macro without the need for them to have to play with the code.
Ideally, I would like to design a user form that asks the user to specify
the: (i) worksheets being compared, (ii) ranges to compare, (iii) column in
which the text is to be added, (iv) actual text to be added.
I did try using a Do Until Loop with the IsEmpty command, but ran into
problems.
I'm no expert with VBA, but I know enough to be dangerous. I can also design
the user form, but getting the coding right is where I'm having problems.
However, I would be happy to consider other suggestions if this could be done
without the need of a user form, as I am unsure how transferable the user
form would be from one workbook to another when staff needed to use the macro
in different workbooks.
Hope this makes sense!
Joe.