Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Display required succeeding cells value if a cell value A1 is capt

Hi All,

I'm a baby to Excel Programming.

But I've to programme Excel 2003 work book in order that if sth is typed in
the text box control. The code searches all the worksheets and displays the
value in the label control.
I've a textbox control, label control and a command button control in Sheet 1

Now with the below mentioned codes I suceeded to retrieve a cell value in a
lable control.eg:A1. But the problem is, I've no idea to display all the
cells
value(B1 to H1) of that row from where the cell in a row, a data was
retrieved.

Any Idea!!

Please Help!! SOS Please consider!!

Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean
d = "A1: A5000"
Let c = txtbx1.Value

For Each Sh In ActiveWorkbook.Worksheets
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If c = "" Then
MsgBox "You haven't typed anything in the Search Box"
Exit Sub

ElseIf Not b Is Nothing Then
firstAddress = b.Address
lbl1.Caption = b

Do
txtbx2.Value = c
Set b = .FindNext(b)
FoundIt = True
Loop While Not b Is Nothing And b.Address < firstAddress
End If
End With

Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Display required succeeding cells value if a cell value A1 is capt


I appears yo umay be looking for multiple occurances of the data.
Create a new worksheet called Summary and then use the code below.

Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean

DestSht = sheets("Summary")
NewRow = 1


d = "A1: A5000"
Let c = txtbx1.Value

If c = "" Then
MsgBox "You haven't typed anything in the Search Box"
Exit Sub


For Each Sh In ActiveWorkbook.Worksheets
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows)

If Not b Is Nothing Then
firstAddress = b.Address
FoundIt = True

Do
sh.Range("B" & c.row & ":H" & c.row).copy
destination:=DestSht.range("B" & NewRow)
DestSht.Range("A" & Newrow) = sh.name
Newrow = Newrow + 1

Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address < firstAddress
End If
End With

Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181707

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Display required succeeding cells value if a cell value A1 is

Hey!!

run time error: 438
Object doesn't support this property or method and highlights the "Summary"
code line. What is it?


"joel" wrote:


I appears yo umay be looking for multiple occurances of the data.
Create a new worksheet called Summary and then use the code below.

Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean

DestSht = sheets("Summary")
NewRow = 1


d = "A1: A5000"
Let c = txtbx1.Value

If c = "" Then
MsgBox "You haven't typed anything in the Search Box"
Exit Sub


For Each Sh In ActiveWorkbook.Worksheets
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows)

If Not b Is Nothing Then
firstAddress = b.Address
FoundIt = True

Do
sh.Range("B" & c.row & ":H" & c.row).copy
destination:=DestSht.range("B" & NewRow)
DestSht.Range("A" & Newrow) = sh.name
Newrow = Newrow + 1

Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address < firstAddress
End If
End With

Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181707

Microsoft Office Help

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Display required succeeding cells value if a cell value A1 is capt


I left Set out of the statement. found a few other problems. this
should work.

from
DestSht = sheets("Summary")

to
Set DestSht = sheets("Summary")


Make sure you add a sheet Summary manually.



VBA Code:
--------------------


Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean

Set DestSht = Sheets("Summary")
NewRow = 1


d = "A1: A5000"
Let c = txtbx1.Value

If c = "" Then
MsgBox "You haven't typed anything in the Search Box"
Exit Sub
End If

For Each Sh In ActiveWorkbook.Worksheets
If Sh.Name < "Summary" Then
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows)

If Not b Is Nothing Then
firstAddress = b.Address
FoundIt = True

Do
Sh.Range("B" & c.Row & ":H" & c.Row).Copy _
Destination:=DestSht.Range("B" & NewRow)
DestSht.Range("A" & NewRow) = Sh.Name
NewRow = NewRow + 1

Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address < firstAddress
End If
End With
End If
Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If

End Sub


--------------------


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181707

Microsoft Office Help

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Display required succeeding cells value if a cell value A1 is

I inserted a new worksheet named "Summary"
But
I got a run time error '424'
Object required.
Highlighted in yellow the below mentioned code line
Sh.Range("B" & c.Row & ":H" & c.Row).Copy Destination:=DestSht.Range("B" &
NewRow)
Especially, about this new modified code: What it will do?


"joel" wrote:


I left Set out of the statement. found a few other problems. this
should work.

from
DestSht = sheets("Summary")

to
Set DestSht = sheets("Summary")


Make sure you add a sheet Summary manually.




VBA Code:
--------------------



Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean

Set DestSht = Sheets("Summary")
NewRow = 1


d = "A1: A5000"
Let c = txtbx1.Value

If c = "" Then
MsgBox "You haven't typed anything in the Search Box"
Exit Sub
End If

For Each Sh In ActiveWorkbook.Worksheets
If Sh.Name < "Summary" Then
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows)

If Not b Is Nothing Then
firstAddress = b.Address
FoundIt = True

Do
Sh.Range("B" & c.Row & ":H" & c.Row).Copy _
Destination:=DestSht.Range("B" & NewRow)
DestSht.Range("A" & NewRow) = Sh.Name
NewRow = NewRow + 1

Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address < firstAddress
End If
End With
End If
Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If

End Sub



--------------------


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181707

Microsoft Office Help

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Display required succeeding cells value if a cell value A1 is capt


I usually use the variabble c when using the find method since the VBA
help code uses the variable c. You used the variable B instead of c.

from
Sh.Range("B" & c.Row & ":H" & c.Row).Copy _
Destination:=DestSht.Range("B" & NewRow)

to

Sh.Range("B" & b.Row & ":H" & b.Row).Copy _
Destination:=DestSht.Range("B" & NewRow)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181707

Microsoft Office Help

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
Display all cells values of that row from where a cell value retri Msgbox Data not found[_2_] Excel Programming 5 February 22nd 10 02:53 AM
Print "freeze panes" on succeeding pages? kdhelm Excel Discussion (Misc queries) 8 October 10th 08 12:38 AM
Advanced Conditional Formatting Help Required - Change cell colour based on values of other cells [email protected] Excel Programming 1 February 9th 07 12:24 AM
out of a group of cells, if max, then display this other cell beechum1 Excel Worksheet Functions 0 February 12th 06 07:20 AM
how to copy succeeding rows from source workbook to destination w. chris Excel Programming 0 March 8th 05 01:51 PM


All times are GMT +1. The time now is 07:21 AM.

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"