Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Have macro ignore error

I am looking for help on this macro I wrote to get a filename, open a file,
grab some cells, then close the file. What I need help with is having the
macro skip a section (go to line 10) if the file is not found to open. Right
now it will close my workbook I'm dumping info into. Also, any idea why my
variable Caccel would be truncated when it should have 3 decimal places?
Thanks in advance!

For i = 1 To NumMatrices
On Error Resume Next
Fname = "C:\Documents and Settings\My Documents\" & Tname & ".txt"
ChDir _
"C:\Documents and Settings\My Documents\"
Workbooks.OpenText Filename:=Fname, Origin:=437, StartRow:=1,
DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False,
Semicolon:=False, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)),
TrailingMinusNumbers:=True
Cells.Find(What:="release", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Dspeed = ActiveCell.Offset(0, 2).Value
Cells.Find(What:="accel", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Caccel = ActiveCell.Offset(0, 1).Value
ActiveWorkbook.Close
' Workbook = wb1
If Cells(Row, 11) = "" Then
Cells(Row, 11) = Dspeed
Else

End If
If Cells(Row, 12) = "" Then
Cells(Row, 12) = Caccel
Else

End If
If Cells(Row, 12) = 0 Then
Cells(Row, 11) = 0
End If
10 Row = Row + 1
Cells(Row, 2).Select
Tname = Selection


Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Have macro ignore error

On Jun 19, 9:43 am, Seth wrote:
I am looking for help on this macro I wrote to get a filename, open a file,
grab some cells, then close the file. What I need help with is having the
macro skip a section (go to line 10) if the file is not found to open. Right
now it will close my workbook I'm dumping info into. Also, any idea why my
variable Caccel would be truncated when it should have 3 decimal places?
Thanks in advance!

For i = 1 To NumMatrices
On Error Resume Next
Fname = "C:\Documents and Settings\My Documents\" & Tname & ".txt"
ChDir _
"C:\Documents and Settings\My Documents\"
Workbooks.OpenText Filename:=Fname, Origin:=437, StartRow:=1,
DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False,
Semicolon:=False, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)),
TrailingMinusNumbers:=True
Cells.Find(What:="release", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Dspeed = ActiveCell.Offset(0, 2).Value
Cells.Find(What:="accel", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Caccel = ActiveCell.Offset(0, 1).Value
ActiveWorkbook.Close
' Workbook = wb1
If Cells(Row, 11) = "" Then
Cells(Row, 11) = Dspeed
Else

End If
If Cells(Row, 12) = "" Then
Cells(Row, 12) = Caccel
Else

End If
If Cells(Row, 12) = 0 Then
Cells(Row, 11) = 0
End If
10 Row = Row + 1
Cells(Row, 2).Select
Tname = Selection

Next


Hello Seth,

1. Delete the On Error Resume statement
2. Below Fname add this code: If Dir(Fname) = "" Then GoTo 10

Sincerely,
Leieth Ross

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Have macro ignore error

Thanks Leith. What about my question on why my variable is truncated?

"Leith Ross" wrote:

On Jun 19, 9:43 am, Seth wrote:
I am looking for help on this macro I wrote to get a filename, open a file,
grab some cells, then close the file. What I need help with is having the
macro skip a section (go to line 10) if the file is not found to open. Right
now it will close my workbook I'm dumping info into. Also, any idea why my
variable Caccel would be truncated when it should have 3 decimal places?
Thanks in advance!

For i = 1 To NumMatrices
On Error Resume Next
Fname = "C:\Documents and Settings\My Documents\" & Tname & ".txt"
ChDir _
"C:\Documents and Settings\My Documents\"
Workbooks.OpenText Filename:=Fname, Origin:=437, StartRow:=1,
DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False,
Semicolon:=False, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)),
TrailingMinusNumbers:=True
Cells.Find(What:="release", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Dspeed = ActiveCell.Offset(0, 2).Value
Cells.Find(What:="accel", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Caccel = ActiveCell.Offset(0, 1).Value
ActiveWorkbook.Close
' Workbook = wb1
If Cells(Row, 11) = "" Then
Cells(Row, 11) = Dspeed
Else

End If
If Cells(Row, 12) = "" Then
Cells(Row, 12) = Caccel
Else

End If
If Cells(Row, 12) = 0 Then
Cells(Row, 11) = 0
End If
10 Row = Row + 1
Cells(Row, 2).Select
Tname = Selection

Next


Hello Seth,

1. Delete the On Error Resume statement
2. Below Fname add this code: If Dir(Fname) = "" Then GoTo 10

Sincerely,
Leieth Ross


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Have macro ignore error

Nevermind. It was because I declared Caccel as an integer.

"Seth" wrote:

Thanks Leith. What about my question on why my variable is truncated?

"Leith Ross" wrote:

On Jun 19, 9:43 am, Seth wrote:
I am looking for help on this macro I wrote to get a filename, open a file,
grab some cells, then close the file. What I need help with is having the
macro skip a section (go to line 10) if the file is not found to open. Right
now it will close my workbook I'm dumping info into. Also, any idea why my
variable Caccel would be truncated when it should have 3 decimal places?
Thanks in advance!

For i = 1 To NumMatrices
On Error Resume Next
Fname = "C:\Documents and Settings\My Documents\" & Tname & ".txt"
ChDir _
"C:\Documents and Settings\My Documents\"
Workbooks.OpenText Filename:=Fname, Origin:=437, StartRow:=1,
DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False,
Semicolon:=False, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)),
TrailingMinusNumbers:=True
Cells.Find(What:="release", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Dspeed = ActiveCell.Offset(0, 2).Value
Cells.Find(What:="accel", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Caccel = ActiveCell.Offset(0, 1).Value
ActiveWorkbook.Close
' Workbook = wb1
If Cells(Row, 11) = "" Then
Cells(Row, 11) = Dspeed
Else

End If
If Cells(Row, 12) = "" Then
Cells(Row, 12) = Caccel
Else

End If
If Cells(Row, 12) = 0 Then
Cells(Row, 11) = 0
End If
10 Row = Row + 1
Cells(Row, 2).Select
Tname = Selection

Next


Hello Seth,

1. Delete the On Error Resume statement
2. Below Fname add this code: If Dir(Fname) = "" Then GoTo 10

Sincerely,
Leieth Ross


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
# Value error and how to ignore blank cells Dannn78 Excel Worksheet Functions 2 July 30th 09 06:18 AM
Ignore macro run time error phil Excel Discussion (Misc queries) 4 March 27th 08 12:11 PM
Ignore Error '1004' help skito1 Excel Programming 1 July 26th 06 06:35 AM
how can i ignore an error in a formula hotelmasters Excel Worksheet Functions 3 June 14th 06 01:13 AM
Ignore Error 1004 akyhne[_2_] Excel Programming 5 September 10th 04 06:29 AM


All times are GMT +1. The time now is 01:24 AM.

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

About Us

"It's about Microsoft Excel"