leeksleeks
Board Regular
- Joined
- Oct 31, 2013
- Messages
- 96
Hi,
I am running a macro for a results based spreadsheet and the data it imports sometimes appears on different rows. This then trips up my macro and I get the error message 'Run time error 1004: No data was selected to parse. The problem occurs when it references "Row 70" in all the lines of the below code as sometimes the information it is trying to use is in "Row 69". Below is the part of my code where you can see how many time row 70 is used. Is there any way if there is an error for it to use row 69 instead?
Range("A70").Select
Selection.TextToColumns Destination:=Range("A70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("B70").Select
Selection.TextToColumns Destination:=Range("B70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("C70").Select
Selection.TextToColumns Destination:=Range("C70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=")", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("D70").Select
Selection.TextToColumns Destination:=Range("D70"), DataType:=xlFixedWidth, _
OtherChar:=")", FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(12, 1), Array(17 _
, 1), Array(23, 1), Array(27, 1), Array(32, 1)), TrailingMinusNumbers:=True
Range("E70:J70").Select
Selection.ClearContents
Range("B70:D70").Select
Selection.Cut Destination:=Range("D70:F70")
Range("B70:F70").Select
Selection.Cut Destination:=Range("D70:H70")
Range("A70").Select
Selection.TextToColumns Destination:=Range("A70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, OtherChar _
:=")", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("A70").Select
Selection.ClearContents
Range("B70").Select
Selection.Cut Destination:=Range("A70")
Range("F70").Select
Selection.Cut Destination:=Range("B70")
Range("G70").Select
Selection.Cut Destination:=Range("C70")
Range("H70").Select
Selection.Cut Destination:=Range("D70")
I look forward to hearing if there is a possible solution to this problem.
Cheers
I am running a macro for a results based spreadsheet and the data it imports sometimes appears on different rows. This then trips up my macro and I get the error message 'Run time error 1004: No data was selected to parse. The problem occurs when it references "Row 70" in all the lines of the below code as sometimes the information it is trying to use is in "Row 69". Below is the part of my code where you can see how many time row 70 is used. Is there any way if there is an error for it to use row 69 instead?
Range("A70").Select
Selection.TextToColumns Destination:=Range("A70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("B70").Select
Selection.TextToColumns Destination:=Range("B70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("C70").Select
Selection.TextToColumns Destination:=Range("C70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=")", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("D70").Select
Selection.TextToColumns Destination:=Range("D70"), DataType:=xlFixedWidth, _
OtherChar:=")", FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(12, 1), Array(17 _
, 1), Array(23, 1), Array(27, 1), Array(32, 1)), TrailingMinusNumbers:=True
Range("E70:J70").Select
Selection.ClearContents
Range("B70:D70").Select
Selection.Cut Destination:=Range("D70:F70")
Range("B70:F70").Select
Selection.Cut Destination:=Range("D70:H70")
Range("A70").Select
Selection.TextToColumns Destination:=Range("A70"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, OtherChar _
:=")", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("A70").Select
Selection.ClearContents
Range("B70").Select
Selection.Cut Destination:=Range("A70")
Range("F70").Select
Selection.Cut Destination:=Range("B70")
Range("G70").Select
Selection.Cut Destination:=Range("C70")
Range("H70").Select
Selection.Cut Destination:=Range("D70")
I look forward to hearing if there is a possible solution to this problem.
Cheers