don1
05-29-2006, 03:26 PM
vba beginner, the macro should work fine but if I want to close the file, get run-time error 424.
Any help ? Thanks
:dunno
Sub CopyName()
Dim rFound As Range
Dim rRnge As Range
Dim strName As String
Dim strCust As String
Set rRnge = Sheet1.Range("B3")
strName = Sheet1.Range("A1").Value
strCust = Sheet1.Range("B3").Value
Windows(2).Activate
On Error Resume Next
ActiveWorkbook.Sheets("Sheet1").Activate
Set rFound = Cells.Find(What:=strName, after:=Range("A1"), _
searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
rFound.Select
rFound.Offset(0, 1).Value = strCust
rFound.Offset(0, 2).Value = rRnge.Offset(0, 1).Value
rFound.Offset(0, 3).Value = rRnge.Offset(0, 2).Value
rFound.Offset(0, 5).Value = rRnge.Offset(1, 0).Value
End Sub
Any help ? Thanks
:dunno
Sub CopyName()
Dim rFound As Range
Dim rRnge As Range
Dim strName As String
Dim strCust As String
Set rRnge = Sheet1.Range("B3")
strName = Sheet1.Range("A1").Value
strCust = Sheet1.Range("B3").Value
Windows(2).Activate
On Error Resume Next
ActiveWorkbook.Sheets("Sheet1").Activate
Set rFound = Cells.Find(What:=strName, after:=Range("A1"), _
searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
rFound.Select
rFound.Offset(0, 1).Value = strCust
rFound.Offset(0, 2).Value = rRnge.Offset(0, 1).Value
rFound.Offset(0, 3).Value = rRnge.Offset(0, 2).Value
rFound.Offset(0, 5).Value = rRnge.Offset(1, 0).Value
End Sub