Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
# Value error and how to ignore blank cells | Excel Worksheet Functions | |||
Ignore macro run time error | Excel Discussion (Misc queries) | |||
Ignore Error '1004' help | Excel Programming | |||
how can i ignore an error in a formula | Excel Worksheet Functions | |||
Ignore Error 1004 | Excel Programming |