#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Stumped

I am stumped

I have 2 routines the 1st ( Sub NextRow() ) is designed to take me to the
first row which has the text "NoXXX", and it works fine.

The 2nd routine is suppose to populate some TextBoxes on my UserForm and
that is not working. The code selects a starting point (cell A3) then it
calls NextRow to find the 1st occurrence of NoXXX, but when the remainder of
the code runs to populate the TextBoxes it is getting its data from row 3.
Even though the cell with the occurrence of NoXXX is selected.

Any ideas?


Sub NextRow()
'
' Macro4 Macro
'

'
Cells.Find(What:="NoXXX", After:=ActiveCell, LookIn:=xlFormulas, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Select

End Sub

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

Private Sub UserForm_Initialize()

Dim rng
Set rng = Cells(ActiveCell.Row, 1)


'No Show #1 Data


'Range("A3").Select

Call NextRow

TextBox1.Value = rng(1, 4) & " " & rng(1, 3)
TextBox2.Value = rng(1, 6)
Me.TextBox2.Value = Format$(TextBox2.Value, "ddd dd mmm yy")
TextBox3.Value = rng(1, 7)
TextBox4.Value = rng(1, 8)
TextBox5.Value = rng(1, 13)
Me.TextBox5.Value = Format$(TextBox5.Value, "ddd dd mmm yy")
TextBox6.Value = rng(1, 15)


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Stumped

Hi

Set the 'rng' variable after calling NextRow, or better (without
selecting any cell) do it like this:

Private Sub UserForm_Initialize()
Dim TargetRow As Long

'No Show #1 Data
TargetRow = Cells.Find(What:="NoXXX", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Row + 1


TextBox1.Value = Cells(TargetRow, 4) & " " & Cells(TargetRow, 3)
TextBox2.Value = Cells(TargetRow, 6)
Me.TextBox2.Value = Format$(TextBox2.Value, "ddd dd mmm yy")
TextBox3.Value = Cells(TargetRow, 7)
TextBox4.Value = Cells(TargetRow, 8)
TextBox5.Value = Cells(TargetRow, 13)
Me.TextBox5.Value = Format$(TextBox5.Value, "ddd dd mmm yy")
TextBox6.Value = Cells(TargetRow, 15)

End Sub

Regards,
Per


On 15 Jul., 22:40, "Patrick C. Simonds" wrote:
I am stumped

I have 2 routines the 1st ( *Sub NextRow() *) is designed to take me to the
first row which has the text *"NoXXX", and it works fine.

The 2nd routine is suppose to populate some TextBoxes on my UserForm and
that is not working. The code selects a starting point (cell A3) then it
calls NextRow to find the 1st occurrence of NoXXX, but when the remainder of
the code runs to populate the TextBoxes it is getting its data from row 3..
Even though the cell with the occurrence of NoXXX is selected.

Any ideas?

Sub NextRow()
'
' Macro4 Macro
'

'
* * Cells.Find(What:="NoXXX", After:=ActiveCell, LookIn:=xlFormulas, LookAt
_
* * * * :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
* * * * False, SearchFormat:=False).Select

End Sub

---------------------------------------------------------------------------*-------------

Private Sub UserForm_Initialize()

Dim rng
Set rng = Cells(ActiveCell.Row, 1)

'No Show #1 Data

* * 'Range("A3").Select

* * Call NextRow

* * TextBox1.Value = rng(1, 4) & " " & rng(1, 3)
* * TextBox2.Value = rng(1, 6)
* * * * Me.TextBox2.Value = Format$(TextBox2.Value, "ddd dd mmm yy")
* * TextBox3.Value = rng(1, 7)
* * TextBox4.Value = rng(1, 8)
* * TextBox5.Value = rng(1, 13)
* * * * Me.TextBox5.Value = Format$(TextBox5.Value, "ddd dd mmm yy")
* * TextBox6.Value = rng(1, 15)

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
Stumped Formula question Excel Discussion (Misc queries) 1 April 16th 08 06:39 PM
stumped ?? my Excel Worksheet Functions 2 April 13th 06 12:32 PM
This has me stumped! parteegolfer Excel Programming 1 March 20th 06 02:59 PM
Stumped Andibevan[_4_] Excel Programming 6 December 23rd 05 03:03 PM
Still stumped Robertgn Excel Worksheet Functions 3 December 10th 05 01:40 AM


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