Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Start on select cell

Hello

I have finally work out how to make search cell to find the infomation i
need form a spreedsheet but i have a problem. when i run the programe it
starts the search from cell A1 but my the infomation starts in cell A8 and
thats were i need the search to start

i have put the code below any help would be great.

Sub batchlocation()

Dim R2 As Range
Set R2 = Range("C4")
Dim R3 As Range
Set R3 = Range("D4")
Dim R4 As Range
Set R4 = Range("E4")
Dim R5 As Range
Set R5 = Range("F4")

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 R = ActiveCell.CurrentRegion

lastRow = R.Rows.Count

n = 8

For k = 1 To lastRow
R.Cells(k).Select
If Cells(2, 4) = R.Cells(k).Value Then
ActiveCell.Select
ActiveCell.Offset(0, -2).Copy
R2.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 2).Copy
R3.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 4).Copy
R4.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 5).Copy
R5.Select
ActiveCell.PasteSpecial
R.Select
n = n + 1
End If

Next k

If n = 8 Then
MsgBox "Batch was not found."
End If

Range("d1").Select

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Start on select cell

change


Set R = ActiveCell.CurrentRegion

lastRow = R.Rows.Count
n = 8
For k = 1 To lastRow


to

Range("D8").Select
Set R = ActiveCell.CurrentRegion
lastRow = R.Rows.Count
Set R = Range("A8", R(R.count))
n = 8
for k = 1 to lastrow - 7

--
Regards,
Tom Ogilvy

"Leon" wrote:

Hello

I have finally work out how to make search cell to find the infomation i
need form a spreedsheet but i have a problem. when i run the programe it
starts the search from cell A1 but my the infomation starts in cell A8 and
thats were i need the search to start

i have put the code below any help would be great.

Sub batchlocation()

Dim R2 As Range
Set R2 = Range("C4")
Dim R3 As Range
Set R3 = Range("D4")
Dim R4 As Range
Set R4 = Range("E4")
Dim R5 As Range
Set R5 = Range("F4")

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 R = ActiveCell.CurrentRegion

lastRow = R.Rows.Count

n = 8

For k = 1 To lastRow
R.Cells(k).Select
If Cells(2, 4) = R.Cells(k).Value Then
ActiveCell.Select
ActiveCell.Offset(0, -2).Copy
R2.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 2).Copy
R3.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 4).Copy
R4.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 5).Copy
R5.Select
ActiveCell.PasteSpecial
R.Select
n = n + 1
End If

Next k

If n = 8 Then
MsgBox "Batch was not found."
End If

Range("d1").Select

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Start on select cell

it works great thank you very much but can i ask one more question,

If Cells(2, 4) = R.Cells(k).Value Then
ActiveCell.Select
ActiveCell.Offset(0, -2).Copy
R2.Select
ActiveCell.PasteSpecial
R.Select


the above code works only for the first cell of the range for exsample it
will find the info i need 10 cells down paste the frist part then in will go
back to the top of the worksheet when i need to past all the info from the
same line i know it's because i have use R.select but im not sure where to go
from there.

"Tom Ogilvy" wrote:

change


Set R = ActiveCell.CurrentRegion

lastRow = R.Rows.Count
n = 8
For k = 1 To lastRow


to

Range("D8").Select
Set R = ActiveCell.CurrentRegion
lastRow = R.Rows.Count
Set R = Range("A8", R(R.count))
n = 8
for k = 1 to lastrow - 7

--
Regards,
Tom Ogilvy

"Leon" wrote:

Hello

I have finally work out how to make search cell to find the infomation i
need form a spreedsheet but i have a problem. when i run the programe it
starts the search from cell A1 but my the infomation starts in cell A8 and
thats were i need the search to start

i have put the code below any help would be great.

Sub batchlocation()

Dim R2 As Range
Set R2 = Range("C4")
Dim R3 As Range
Set R3 = Range("D4")
Dim R4 As Range
Set R4 = Range("E4")
Dim R5 As Range
Set R5 = Range("F4")

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 R = ActiveCell.CurrentRegion

lastRow = R.Rows.Count

n = 8

For k = 1 To lastRow
R.Cells(k).Select
If Cells(2, 4) = R.Cells(k).Value Then
ActiveCell.Select
ActiveCell.Offset(0, -2).Copy
R2.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 2).Copy
R3.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 4).Copy
R4.Select
ActiveCell.PasteSpecial
R.Select
ActiveCell.Select
ActiveCell.Offset(0, 5).Copy
R5.Select
ActiveCell.PasteSpecial
R.Select
n = n + 1
End If

Next k

If n = 8 Then
MsgBox "Batch was not found."
End If

Range("d1").Select

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
how to select a range that start in diferent row Pasmatos Excel Discussion (Misc queries) 2 November 28th 05 07:00 PM
select dynamic range with dynamic start point Juli Excel Programming 1 August 31st 05 12:05 AM
Rank items, select one start date, have remaining dates follow based on rank rob normerica Excel Discussion (Misc queries) 1 August 15th 05 09:36 PM
Userform to select start date and end date Johnny B. Excel Programming 0 November 28th 03 05:56 PM


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