I am trying to copy some cells in vba based on their column, from an excel file chosen by the user (req), to another fixed file (rfqq). below is my code which brings error 424,
you need to define the variable req
as a workbook object, and use a different string for the name of the workbook you want to open.
so change your code as below:
Dim rfq As Workbook, req as Workbook '~~>Change 'req' to Workbook type
Dim vBookName as variant '~~>Add new variant to capture the name
Dim rowcount As Integer, rfqc As Integer, reqab As Integer, i As Integer
'~~>without 'As Integer' statements, all but the last one of these was a variant
vBookName = Application.GetOpenFilename '~~>replace 'req' w 'vBookName' in this section
If vBookName = False Then
MsgBox "No file specified.", vbExclamation, "Duh!!!"
Exit Sub
Else
Set req = Workbooks.Open(Filename:=vBookName) '~~> Use 'Set' as 'req' is an object
End If
rowcount = ActiveSheet.UsedRange.Rows.Count
Set rfq = Workbooks.Open("c:\users\mostafa\desktop\rfqq.xlsx")