G
Guest
Hello, all:
I'm using Excel 2003. I'm trying to write a very simple program to copy
cells from one worksheet to another based upon the two worksheets having at
least one common column of data.
The user needs to enter onto a sheet called COPIER the names of the source
workbook and worksheet as well as the recipient workbook and worksheet. I
then want to use the contents of those cells in the routine. Problem is, I
don't know the proper syntax for loading them into a Set statement. Here is
part of the code:
**************************************
Dim COPIER, SOURCE, RECIPIENT As Object
Set COPIER = ActiveSheet
SBOOKNAME = COPIER.Cells(9, 4)'this is the name of the source workbook
SSHEETNAME = COPIER.Cells(11, 4)'this is the name of the source worksheet
RBOOKNAME = COPIER.Cells(9, 4)'name of recipient workbook
RSHEETNAME = COPIER.Cells(11, 4)'name of recipient worksheet
'Here is the problem code (I tried two variations, neither worked):
Set SOURCE = Workbooks(SBOOKNAME).Sheets(SSHEETNAME)'gives a subscript out
of range error
Set RECIPIENT =
Workbooks(COPIER.Range("K9")).Sheets(COPIER.Range("K11"))'gives a type
mismatch error. I also tried this with .Cells(), which didn't work either
**************************************
Anyone know the proper syntax for reading from cells and including the cell
contents in a Set statement?
Thanks in advance,
MARTY
I'm using Excel 2003. I'm trying to write a very simple program to copy
cells from one worksheet to another based upon the two worksheets having at
least one common column of data.
The user needs to enter onto a sheet called COPIER the names of the source
workbook and worksheet as well as the recipient workbook and worksheet. I
then want to use the contents of those cells in the routine. Problem is, I
don't know the proper syntax for loading them into a Set statement. Here is
part of the code:
**************************************
Dim COPIER, SOURCE, RECIPIENT As Object
Set COPIER = ActiveSheet
SBOOKNAME = COPIER.Cells(9, 4)'this is the name of the source workbook
SSHEETNAME = COPIER.Cells(11, 4)'this is the name of the source worksheet
RBOOKNAME = COPIER.Cells(9, 4)'name of recipient workbook
RSHEETNAME = COPIER.Cells(11, 4)'name of recipient worksheet
'Here is the problem code (I tried two variations, neither worked):
Set SOURCE = Workbooks(SBOOKNAME).Sheets(SSHEETNAME)'gives a subscript out
of range error
Set RECIPIENT =
Workbooks(COPIER.Range("K9")).Sheets(COPIER.Range("K11"))'gives a type
mismatch error. I also tried this with .Cells(), which didn't work either
**************************************
Anyone know the proper syntax for reading from cells and including the cell
contents in a Set statement?
Thanks in advance,
MARTY