Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Yo Yo is offline
external usenet poster
 
Posts: 3
Default Help... This code consistently crashes for no reason.

I am not sure if posting code is a faux pas, but it is a really simple one.
Even though it crashes everytime I run it...Why?
Thanks in advance,
Yo.

Sub explainLocations()
Dim wbL As Workbook, wbT As Workbook
Dim wsT As Worksheet, wsL As Worksheet
Dim rT As Range, rE As Range, rW As Range
Dim rC As Range, rL As Range
Dim swb As String

Set wbL = Workbooks(ActiveWorkbook.Name)
Set wsL = Worksheets(wbL.ActiveSheet.Name)
Set rL = wsL.Range("B1", Range("B1").End(xlToRight).Address(0, 0))

For Each rC In rL.Cells
Set rW = Range(c.Address(0, 0))
swb = "C:\Documents and Settings\Me\Desktop\Web\" & wsL.Name & "\" &
rC.Value
Set wbT = Workbooks.Open(swb)
Set wsT = Worksheets(wbT.ActiveSheet.Name)
Set rT = wsT.Range("A1", Range("B1000").End(xlUp).Address(0, 0))
For Each rE In rT.Cells
If rE.Font.Underline = "2" Then
Set rW = rW.Offset(1, 0)
rW.Value = rE.Value
End If
Next
Set wsT = Nothing
Set rT = Nothing
wbT.Close
Set wbT = Nothing
Next
Set rW = Nothing
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help... This code consistently crashes for no reason.

the only thing I can see wrong
is c is not defined

Set rW = Range(c.Address(0, 0))


should it be Rc

Set rW = Range(Rc.Address(0, 0)

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
Yo Yo is offline
external usenet poster
 
Posts: 3
Default Help... This code consistently crashes for no reason.

It still doesn't work... (You were right about 'c' being 'rC'. For the
post, I tried to change all the 'c' to 'rC' to make it easier to read.) I
have tried this sub on multiple computers with multiple Exel versions.
Everyone of them eternally hangs.


"mudraker " wrote in message
...
the only thing I can see wrong
is c is not defined

Set rW = Range(c.Address(0, 0))


should it be Rc

Set rW = Range(Rc.Address(0, 0))


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Help... This code consistently crashes for no reason.

to top of module, add Option Explicit and then compile

Error= Set rW = Range(c.Address(0, 0))
c is not defined

If it is meant to be rC then try this re-write

Sub explainLocations()
Dim wbL As Workbook, wbT As Workbook
Dim wsT As Worksheet, wsL As Worksheet
Dim rT As Range, rE As Range, rW As Range
Dim rC As Range, rL As Range
Dim swb As String

Set wbL = ActiveWorkbook
Set wsL = wbL.ActiveSheet
Set rL = wsL.Range("B1", wsL.Range("B1").End
(xlToRight).Address(0, 0))

For Each rC In rL
swb = "C:\Documents and Settings\Me\Desktop\Web\" &
wsL.Name & "\" & rC.Value
Set wbT = Workbooks.Open(swb)
Set wsT = wbT.ActiveSheet
Set rT = wsT.Range("A1", wsT.Range("B1000").End
(xlUp).Address(0, 0))
'fairly pointless because multiple occurrences will
mean the cell gets overwritten
For Each rE In rT
If rE.Font.Underline = xlUnderlineStyleSingle Then
rC.Offset(1, 0).Value = rE.Value
End If
Next
Set rT = Nothing
Set wsT = Nothing
'possible error here
wbT.Close
Set wbT = Nothing
Next
End Sub

Kevin Beckham

-----Original Message-----
I am not sure if posting code is a faux pas, but it is a

really simple one.
Even though it crashes everytime I run it...Why?
Thanks in advance,
Yo.

Sub explainLocations()
Dim wbL As Workbook, wbT As Workbook
Dim wsT As Worksheet, wsL As Worksheet
Dim rT As Range, rE As Range, rW As Range
Dim rC As Range, rL As Range
Dim swb As String

Set wbL = Workbooks(ActiveWorkbook.Name)
Set wsL = Worksheets(wbL.ActiveSheet.Name)
Set rL = wsL.Range("B1", Range("B1").End

(xlToRight).Address(0, 0))

For Each rC In rL.Cells
Set rW = Range(c.Address(0, 0))
swb = "C:\Documents and Settings\Me\Desktop\Web\" &

wsL.Name & "\" &
rC.Value
Set wbT = Workbooks.Open(swb)
Set wsT = Worksheets(wbT.ActiveSheet.Name)
Set rT = wsT.Range("A1", Range("B1000").End

(xlUp).Address(0, 0))
For Each rE In rT.Cells
If rE.Font.Underline = "2" Then
Set rW = rW.Offset(1, 0)
rW.Value = rE.Value
End If
Next
Set wsT = Nothing
Set rT = Nothing
wbT.Close
Set wbT = Nothing
Next
Set rW = Nothing
End Sub


.

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
Vlookup not working consistently Julie B. Excel Worksheet Functions 3 June 4th 08 01:27 AM
How do I get filtering to behave consistently? Steve Excel Worksheet Functions 0 April 25th 07 11:50 AM
Code crashes after clearing comments L. Howard Kittle Excel Worksheet Functions 2 February 20th 06 04:54 AM
CPU Usage consistently above 75% hparteep Excel Discussion (Misc queries) 1 October 27th 05 02:56 PM
Code in ThisWorkbook crashes Excel Pat Beck Excel Programming 6 August 25th 03 09:07 AM


All times are GMT +1. The time now is 09:56 PM.

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"