Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What could be the error?


Hi All,
I have this scripit in my form to add a new membership no. to the data
base entries. This works fine if I run it from the same sheet where
the data is. If I try to run this code from sheet 2 it gives me an
error.

With Sheets("Member_DataBase")

iRow = .Cells(.Rows.Count, 2).End(xlUp).Row
..Cells(iRow, 1).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
End With

The error is at .Cell(iRow.....
it says wrong way of selection or something to that effect.
Appreciate any help please?

Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=505899

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default What could be the error?

You can't 'Select' anything that isn't on the ActiveSheet.

If you begin with Sheets("Member_DataBase").Select or .Activate, it
should be OK.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default What could be the error?

Hi Syed,

Try prepending:

Cells(iRow, 1).Select


with a dot:

.Cells(iRow, 1).Select

Better still, remove the selectio, e.g.:

With Sheets("Member_DataBase")
iRow = .Cells(.Rows.Count, 2).End(xlUp).row
Cells(iRow, 1).FormulaR1C1 = "=R[-1]C+1"
End With



---
Regards,
Norman



"saziz" wrote in
message ...

Hi All,
I have this scripit in my form to add a new membership no. to the data
base entries. This works fine if I run it from the same sheet where
the data is. If I try to run this code from sheet 2 it gives me an
error.

With Sheets("Member_DataBase")

iRow = .Cells(.Rows.Count, 2).End(xlUp).Row
Cells(iRow, 1).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
End With

The error is at .Cell(iRow.....
it says wrong way of selection or something to that effect.
Appreciate any help please?

Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile:
http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=505899



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default What could be the error?

You can not select or activate on a sheet that is not the active sheet. You
have two choices. Either select the sheet prior to the select or rewrite the
code to avoid all of the selects. To avoid the select you need to get
yourself comfortable with range objects. Range objects are just like the
active cell except better in that you can have as many as you want and they
do not have to be on the active sheet.
--
HTH...

Jim Thomlinson


"saziz" wrote:


Hi All,
I have this scripit in my form to add a new membership no. to the data
base entries. This works fine if I run it from the same sheet where
the data is. If I try to run this code from sheet 2 it gives me an
error.

With Sheets("Member_DataBase")

iRow = .Cells(.Rows.Count, 2).End(xlUp).Row
.Cells(iRow, 1).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
End With

The error is at .Cell(iRow.....
it says wrong way of selection or something to that effect.
Appreciate any help please?

Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=505899


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What could be the error?


JakeyC
Thank you, it worked perfectly.
syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=505899



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default What could be the error?



--
---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Syed,

Try prepending:

Cells(iRow, 1).Select


with a dot:

.Cells(iRow, 1).Select

Better still, remove the selectio, e.g.:

With Sheets("Member_DataBase")
iRow = .Cells(.Rows.Count, 2).End(xlUp).row
Cells(iRow, 1).FormulaR1C1 = "=R[-1]C+1"
End With



---
Regards,
Norman



"saziz" wrote in
message ...

Hi All,
I have this scripit in my form to add a new membership no. to the data
base entries. This works fine if I run it from the same sheet where
the data is. If I try to run this code from sheet 2 it gives me an
error.

With Sheets("Member_DataBase")

iRow = .Cells(.Rows.Count, 2).End(xlUp).Row
Cells(iRow, 1).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
End With

The error is at .Cell(iRow.....
it says wrong way of selection or something to that effect.
Appreciate any help please?

Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile:
http://www.excelforum.com/member.php...fo&userid=6350
View this thread:
http://www.excelforum.com/showthread...hreadid=505899





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default What could be the error?

Hi Syed,

Please igno

Try prepending:

Cells(iRow, 1).Select


with a dot:

.Cells(iRow, 1).Select


and try the second suggestion of removing selections.

--
---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Syed,

Try prepending:

Cells(iRow, 1).Select


with a dot:

.Cells(iRow, 1).Select

Better still, remove the selectio, e.g.:

With Sheets("Member_DataBase")
iRow = .Cells(.Rows.Count, 2).End(xlUp).row
Cells(iRow, 1).FormulaR1C1 = "=R[-1]C+1"
End With



---
Regards,
Norman



"saziz" wrote in
message ...

Hi All,
I have this scripit in my form to add a new membership no. to the data
base entries. This works fine if I run it from the same sheet where
the data is. If I try to run this code from sheet 2 it gives me an
error.

With Sheets("Member_DataBase")

iRow = .Cells(.Rows.Count, 2).End(xlUp).Row
Cells(iRow, 1).Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
End With

The error is at .Cell(iRow.....
it says wrong way of selection or something to that effect.
Appreciate any help please?

Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile:
http://www.excelforum.com/member.php...fo&userid=6350
View this thread:
http://www.excelforum.com/showthread...hreadid=505899





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"