Having trouble with this code
Ossie,
That was the problem right there (end if). But for some reason it doesnt
split the first cell like I want it to when I run it again. Also when I run
it again it freezes up. Maybe I have my loop wrong?
"OssieMac" wrote:
If you used Joel's code did you add the end if like this:-
if InStr(Text, " ") 0 then
Text = Trim(Mid(Text, InStr(Text, " ")))
end if
Regards,
OssieMac
"Nolaughmtr" wrote:
thanks gents,
but now im getting a error "loop with out do"?
"Joel" wrote:
Instr will cause an error if it doesn't find a space. Put in this fix. You
may also want to trim text if it doesn't find a space.
if InStr(Text, " ") 0 then
Text = Trim(Mid(Text, InStr(Text, " ")))
"Nolaughmtr" wrote:
I get an error at " <<<<" when i try an run it again. basically im
trying to coppy information from one page to another and then splitting the
fist row on the second page. I would also like help on trying to add more
information from the 1st sheet to the second sheet. its not constant
information so im a bit confused on how to do it. If anyone wants to look at
the file please let me know because I know this is pretty confusing.
Sub copy_1()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("we 9-8-07").Range("F2:G93")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("DIE STATUS")
Lr = DestSheet.Cells(Rows.count, "A").End(xlUp).Row
'With the information from the LastRow function we can
'create a destination cell and copy/paste the source range
Set DestRange = DestSheet.Range("A" & Lr + 1)
SourceRange.COPY DestRange
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Worksheets("DIE STATUS").Activate
cellCount = 2
With Worksheets("Die status")
Do While Cells(cellCount, "A") < ""
Number = Val(Cells(cellCount, "A"))
Text = Cells(cellCount, "A")
Text = Trim(Mid(Text, InStr(Text, " ")))<<<<
.Cells(cellCount, "A") = Number
.Cells(cellCount, "C") = Text
cellCount = cellCount + 1
Loop
End With
End Sub
|