Cozkincaud
New Member
- Joined
- Apr 18, 2019
- Messages
- 8
I need to copy the ActiveCell.Address to a string variable to test if a cell is in a range for the Intersect function. I would be very grateful to anyone who could resolve this problem for me. I would also be grateful for any suggestions or comments on the other code in this macro.
My thanks in advance for your comments and suggestions. Here is the macro:
Dim QualifierRange As Range
Dim StrVal As Range ‘NOTE: I also run the macro with "StrVall As String"
QualifierRange = Sheets("Tags III").Range("E43:E50"
Set QualifierRange = Range
Set StrVal = ActiveCell.Address 'Error is 'Type Mismatch' if I Dim Strval as 'Range'. If I Dim it as 'String' i get an 'Object required' error.
If Intersect(QualifierRange, StrVal) Is Nothing Then
ActiveCell.Select
Selection.Copy
Sheets("Tags Insert").Select
Range("G14").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Select
Selection.Copy
Sheets("Tags Insert").Select
Range("G8").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
End Sub
The macro is intended to copy a cell value and then paste it in another worksheet (TagsInsert). Where It will be pasted in this other sheet (TagsInsert) depends on if the copied cell is in a specified range (QualifierRange)
My thanks in advance for your comments and suggestions. Here is the macro:
Dim QualifierRange As Range
Dim StrVal As Range ‘NOTE: I also run the macro with "StrVall As String"
QualifierRange = Sheets("Tags III").Range("E43:E50"
Set QualifierRange = Range
Set StrVal = ActiveCell.Address 'Error is 'Type Mismatch' if I Dim Strval as 'Range'. If I Dim it as 'String' i get an 'Object required' error.
If Intersect(QualifierRange, StrVal) Is Nothing Then
ActiveCell.Select
Selection.Copy
Sheets("Tags Insert").Select
Range("G14").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Select
Selection.Copy
Sheets("Tags Insert").Select
Range("G8").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
End Sub
The macro is intended to copy a cell value and then paste it in another worksheet (TagsInsert). Where It will be pasted in this other sheet (TagsInsert) depends on if the copied cell is in a specified range (QualifierRange)