Reputation: 63
Sub tcptiff()
Dim TCP As String
Dim eebo As String
Dim tiff As String
Dim facpage As String
On Error GoTo Errorcatch
TCP = Range("F1").Value
tiff = Range("F2").Value
eebo = ActiveCell(0, 0).Value
facpage = ActiveCell(, 3).Value
If IsEmpty(Range(ActiveCell(, 3))) = False Then
If Len(eebo) = 2 Then
ActiveCell(, 1).Value = TCP & "-" & "00" & Left(eebo, 1) & "-" & Right(eebo, 1)
ActiveCell(, 2).Value = tiff & "_Page_" & facpage
ElseIf Len(eebo) = 3 Then
ActiveCell(, 1).Value = TCP & "-" & "0" & Left(eebo, 2) & "-" & Right(eebo, 1)
ActiveCell(, 2).Value = tiff & "_Page_" & facpage
End If
End If
Errorcatch:
MsgBox Err.Description
End Sub
I'm trying to write an excel macro so that it fills out two columns with relevant information from adjacent cells. I wrote the macro in Sheet2 Code. I keep getting Method 'Range' of object'_Worksheet' failed. What is the problem? I tried to specify the worksheet, but that doesn't fix the problem.
Upvotes: 0
Views: 274
Reputation: 1439
The problem is in:
If IsEmpty(Range(ActiveCell(, 3))) = False Then
ActiveCell(, 3) is already a Range so :
If IsEmpty(ActiveCell(, 3)) = False Then
Upvotes: 1