LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Return to Previous Sheet

Hi All

Had some fantastic help from Tom yesterday and it worked perfectly no
problem - however today when I added to the "Result Sheet" I had to close
down the UserForm and start again with the ActiveSheet I was using to search
again for more info.
Below is the code from yesterday followed by Adding the info found to the
"Result Sheet" how do I get back to my previous Active Sheet.

Private Sub Cmd100_Click()
Dim rngToSearch As Range
Dim rngFound As Range
Set rngToSearch = ActiveSheet.Columns("F")
Set rngFound = rngToSearch.Find(What:=Tb100.Value, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry " & Tb100.Value & " was not found."
Else
With Lb1
For i = 0 To .ListCount - 1
If .List(i, 5) = Tb100.Value Then
Lb1.ListIndex = i
For Each cell In Range(Cells(rngFound.Row, 7), _
Cells(rngFound.Row, 7))
s = cell.Value & ","
Next
Tb101.Value = Left(s, Len(s) - 1)
Exit For
End If
Next
rngFound.Select
End With
End If


End Sub

Private Sub Cmd2_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Result")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 5) _
.End(xlUp).Offset(1, 0).Row



'copy the data to the database
ws.Cells(iRow, 2).Value = Me.Tb25.Value
ws.Cells(iRow, 3).Value = Me.Tb17.Value
ws.Cells(iRow, 4).Value = Me.Tb18.Value
ws.Cells(iRow, 5).Value = Me.Tb14.Value
ws.Cells(iRow, 6).Value = Me.Tb15.Value
ws.Cells(iRow, 7).Value = Me.Tb16.Value
ws.Cells(iRow, 8).Value = Lb1.List(, 4)
ws.Cells(iRow, 9).Value = Me.Tb2.Text
ws.Cells(iRow, 10).Value = Me.Tb19.Value

'Call Module1.Macro4


'clear the data
Me.Tb2.Text = ""
Me.Tb11.Value = ""
Me.Tb12.Value = ""
Me.Tb13.Value = ""
Me.Tb14.Value = ""
Me.Tb15.Value = ""
Me.Tb16.Value = ""
Me.Tb19.Value = ""
Me.Tb26.Value = ""
Me.Tb27.Value = ""
Me.Tb100.Value = ""



End Sub


--
Many thanks

hazel
 
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
How to return to previous cell? Denise Excel Discussion (Misc queries) 5 April 22nd 23 02:09 AM
How to return to the previous active sheet after hyperlink? Terry Excel Worksheet Functions 5 March 21st 10 02:53 AM
LOOKUP return the value from the previous row Steve Excel Worksheet Functions 5 October 12th 07 11:41 PM
Hyperlink or Other Method To Return To Previous Location (Sheet) Possible? Mhz New Users to Excel 4 August 1st 06 11:39 AM
Return to previous worksheet Mats Samson Excel Programming 3 October 20th 05 08:36 PM


All times are GMT +1. The time now is 03:47 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"