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: 67
Default Code Problems

Hello

Im trying to make a code that will help me find information in a work sheet
like a search/find tool. I have got this far but now im stuck because it
never find any infomation.

I also need to know is there any way to make to it seach in one column
instead of the whole work sheet

here's my code:
Sub BatchLocate()

Label1:
Dim myRange As Range
Dim lastRow As Integer
Dim myNum As Long
Dim myAnswer As String
Dim myCheck As Boolean
Dim n As Integer
Dim k As Integer

Range("D8").Select
Set myRange = ActiveCell.CurrentRegion
lastRow = myRange.Rows.Count
myAnswer = InputBox("Enter Batch Number.")
myCheck = IsNumeric(myAnswer)
If myAnswer < Empty Then
If myCheck = False Then
MsgBox " Please enter a valid batch Number"
GoTo Label1
Else
myNum = CLng(myAnswer)
End If
Else
Range("d2").Select
Exit Sub
End If

Range("d2").Value = myNum
n = 8

For k = 1 To lastRow
myRange.Cells(k).Select
If myRange.Cells(k).Value = myNum Then
Range("B" & n).Value = myNum
ActiveCell.Offset(0, -2).Copy.ActiveSheet.Cells(4, 2).Select.Paste
ActiveCell.Offset(0, 2).Copy.ActiveSheet.Cells(4, 3).Select.Paste
ActiveCell.Offset(0, 4).Copy.ActiveSheet.Cells(4, 4).Select.Paste
ActiveCell.Offset(0, 5).Copy.ActiveSheet.Cells(4, 5).Select.Paste
n = n + 1
End If
Next k
If n = 8 Then
MsgBox "Batch " & myNum & " was not found."
Else
Range("d2").Select
End If

End Sub

Any help would be great.

Thanks
 
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
Code problems [email protected] Excel Programming 0 April 5th 06 10:43 PM
Problems with code tac Excel Programming 2 March 10th 06 03:12 AM
sorting code problems DKY[_15_] Excel Programming 1 September 24th 04 06:41 PM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
VBA Code problems! Simon Lloyd[_463_] Excel Programming 5 May 24th 04 10:21 PM


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