ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA error (https://www.excelbanter.com/excel-programming/340185-excel-vba-error.html)

R Ormerod

Excel VBA error
 
After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod

Jim Thomlinson[_4_]

Excel VBA error
 
Post your code. It is hard to debug that which we can not see. The error you
have can be caused by a number of different things. The most likely culprest
are that you are tryuing to select a cell on a sheet that is not active or
that you are trying to select a cell which does not exist. Such as Cell A0 or
A65537...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod


R Ormerod

Excel VBA error
 
Sheets("xxxx").Select

Dim MaxRowNet05 As Long
Dim a As Long
MaxRowNet05 = Range("E65536").End(xlUp).Row

For a = MaxRowNet05 To 2 Step -1
If Range("E" & a).Value < "C10" Then
'Range("E" & a).Font.Bold = True ' For testing
Range("E" & a).EntireRow.Delete ' Delete the row
End If
Next a

The macro runs through around 10 worksheets with the same code. Each sheet
is unhidden before and rehidden after the code.

--
R Ormerod


"Jim Thomlinson" wrote:

Post your code. It is hard to debug that which we can not see. The error you
have can be caused by a number of different things. The most likely culprest
are that you are tryuing to select a cell on a sheet that is not active or
that you are trying to select a cell which does not exist. Such as Cell A0 or
A65537...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod


George Nicholson[_2_]

Excel VBA error
 
......Or trying to establish a Range reference without specifying a Worksheet
for that range.

I find that 1004 errors are usually caused by not giving Excel enough
information, i.e., assuming it "knows" something that it doesn't or "knows"
what I mean (Excel's psyhic powers are undocumented for a reason: it doesn't
have any).

But, as Jim says. it could be a lot of things.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Jim Thomlinson" wrote in message
...
Post your code. It is hard to debug that which we can not see. The error
you
have can be caused by a number of different things. The most likely
culprest
are that you are tryuing to select a cell on a sheet that is not active or
that you are trying to select a cell which does not exist. Such as Cell A0
or
A65537...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod




Jim Thomlinson[_4_]

Excel VBA error
 
The queston becomes what is different about the sheet that the code crashes
on from the other sheets. Is the sheet protected? Is there no data on the
sheet? What are the values of MaxRowNet05 and a when the code crashes? Once
we figure that out the rest should fall into place...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

Sheets("xxxx").Select

Dim MaxRowNet05 As Long
Dim a As Long
MaxRowNet05 = Range("E65536").End(xlUp).Row

For a = MaxRowNet05 To 2 Step -1
If Range("E" & a).Value < "C10" Then
'Range("E" & a).Font.Bold = True ' For testing
Range("E" & a).EntireRow.Delete ' Delete the row
End If
Next a

The macro runs through around 10 worksheets with the same code. Each sheet
is unhidden before and rehidden after the code.

--
R Ormerod


"Jim Thomlinson" wrote:

Post your code. It is hard to debug that which we can not see. The error you
have can be caused by a number of different things. The most likely culprest
are that you are tryuing to select a cell on a sheet that is not active or
that you are trying to select a cell which does not exist. Such as Cell A0 or
A65537...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod


R Ormerod

Excel VBA error
 
I'll run it tonight and see if I can ascertain which sheet the error is
occurring on.
--
R Ormerod


"Jim Thomlinson" wrote:

The queston becomes what is different about the sheet that the code crashes
on from the other sheets. Is the sheet protected? Is there no data on the
sheet? What are the values of MaxRowNet05 and a when the code crashes? Once
we figure that out the rest should fall into place...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

Sheets("xxxx").Select

Dim MaxRowNet05 As Long
Dim a As Long
MaxRowNet05 = Range("E65536").End(xlUp).Row

For a = MaxRowNet05 To 2 Step -1
If Range("E" & a).Value < "C10" Then
'Range("E" & a).Font.Bold = True ' For testing
Range("E" & a).EntireRow.Delete ' Delete the row
End If
Next a

The macro runs through around 10 worksheets with the same code. Each sheet
is unhidden before and rehidden after the code.

--
R Ormerod


"Jim Thomlinson" wrote:

Post your code. It is hard to debug that which we can not see. The error you
have can be caused by a number of different things. The most likely culprest
are that you are tryuing to select a cell on a sheet that is not active or
that you are trying to select a cell which does not exist. Such as Cell A0 or
A65537...
--
HTH...

Jim Thomlinson


"R Ormerod" wrote:

After running an Excel VBA macro the following error always occurs:

Run-time error '1004':

Select method of Range Class failed

The 'Debug' button is not available and I have not been able to ascertain
why this is happening - any ideas for investigating?

--
R Ormerod



All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com