Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Help with code repair

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with code repair


Dim dX As Double, dCount As Double
with Worksheets("test")
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, .Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To .UsedRange.Rows.Count
If .Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem .Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
end with
End Sub
"Mekinnik" wrote:

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Help with code repair

Sorry but it doesn't work, for some odd reason it will only work with
'activesheet'

"Joel" wrote:


Dim dX As Double, dCount As Double
with Worksheets("test")
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, .Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To .UsedRange.Rows.Count
If .Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem .Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
end with
End Sub
"Mekinnik" wrote:

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with code repair

which statement fails???

"Mekinnik" wrote:

Sorry but it doesn't work, for some odd reason it will only work with
'activesheet'

"Joel" wrote:


Dim dX As Double, dCount As Double
with Worksheets("test")
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, .Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To .UsedRange.Rows.Count
If .Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem .Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
end with
End Sub
"Mekinnik" wrote:

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default Help with code repair

This one
For dX = 1 To .UsedRange.Rows.Count

"Joel" wrote:

which statement fails???

"Mekinnik" wrote:

Sorry but it doesn't work, for some odd reason it will only work with
'activesheet'

"Joel" wrote:


Dim dX As Double, dCount As Double
with Worksheets("test")
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, .Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To .UsedRange.Rows.Count
If .Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem .Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
end with
End Sub
"Mekinnik" wrote:

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with code repair

I'm not seeing any problems, but used range varies with different type date.
I think you need to check if usedrange is returning the same vaule ifthe page
is selected or not selected. If you single step through the code and one
time have Test selected and another time have a different sheet slected do
you get the same results? Your problem may not be with the activesheet.

"Mekinnik" wrote:

This one
For dX = 1 To .UsedRange.Rows.Count

"Joel" wrote:

which statement fails???

"Mekinnik" wrote:

Sorry but it doesn't work, for some odd reason it will only work with
'activesheet'

"Joel" wrote:


Dim dX As Double, dCount As Double
with Worksheets("test")
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, .Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To .UsedRange.Rows.Count
If .Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem .Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
end with
End Sub
"Mekinnik" wrote:

How can I modify the code below to reference a non-active worksheet, I do not
want to use 'Activeworksheet'

Dim dX As Double, dCount As Double
Worksheets("test").Activate
sSelected = Me.Cbo1.Value
dCount = 0
If IsError(Application.Match(sSelected, ActiveSheet.Columns(1), 0)) Then
frm1.Hide
frm2.Show
End If
For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 1).Value = sSelected Then
Me.Cbo2.AddItem Cells(dX, 2).Value
dCount = dCount + 1
End If
Next
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
Unknown repair Barry McConnell Excel Discussion (Misc queries) 1 April 6th 10 04:00 PM
Looking For a repair tool Jim Wilsom Excel Discussion (Misc queries) 3 August 7th 07 07:41 PM
I need to repair an invalid hyperlink S. Banks - Admin. Asst. Excel Worksheet Functions 1 October 23rd 06 03:08 PM
open & repair through vba [email protected] Excel Programming 1 April 10th 06 03:40 PM
detect and repair vs regserver Lucas Budlong Excel Programming 1 February 3rd 06 06:00 PM


All times are GMT +1. The time now is 06:57 PM.

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

About Us

"It's about Microsoft Excel"