Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default declaring active cell inside a for loop and offsetting from it

I have a macro in which the first column of the sheet is searched for
matching itemID. Then from there I want populate a series of textboxe
located in the row with the matching itemID. The length of the row
vary and I am trying to implement my code to
read until a blank cell

here is my code so far
Dim CellQuanValue
Dim CellDesValue
Dim ItemId = some id value
Counter = 1
Dim ItemList As Variant

ItemList = shtItemId.Range("A2:A100").Value
ItemList = shtItemId.Application.WorksheetFunction.Transpose( ItemList)
For i = 1 To UBound(ItemList)
If ItemList(i) = ItemId Then
'Set that cell as active cell???
Do
CellQuanValue = ActiveCell.Offset(0, Counter)
Me.Controls("txtQty" & Counter) = CellQuanValue
CellDesValue = ActiveCell.Offset(0, Counter+1)
Me.Controls("txtDes" & Counter) = CellDesValue
Counter = Counter + 1
'UntilNextCellIs Empty???
End If
Next i

Is there is a way to declare that cell as an active cell or an easie
way to to do this?

thank

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default declaring active cell inside a for loop and offsetting from it

Dim CellQuanValue
Dim CellDesValue
Dim ItemId = some id value
Counter = 1
Dim ItemList As Variant

ItemList = shtItemId.Range("A2:A100").Value
ItemList = shtItemId.Application.WorksheetFunction.Transpose( ItemList)
For i = 1 To UBound(ItemList)
If ItemList(i) = ItemId Then
Range("A2:A100")(i).Activate

Do
CellQuanValue = ActiveCell.Offset(0, Counter)
Me.Controls("txtQty" & Counter) = CellQuanValue
CellDesValue = ActiveCell.Offset(0, Counter+1)
Me.Controls("txtDes" & Counter) = CellDesValue
Counter = Counter + 1
While not isempty(activeCell.offset(0,counter))
Exit For ' a match has been made, on reason to keep looking
End If
Next i

Would be a guess at What you want.

--
Regards,
Tom Ogilvy


"l1075 " wrote in message
...
I have a macro in which the first column of the sheet is searched for a
matching itemID. Then from there I want populate a series of textboxes
located in the row with the matching itemID. The length of the rows
vary and I am trying to implement my code to
read until a blank cell

here is my code so far
Dim CellQuanValue
Dim CellDesValue
Dim ItemId = some id value
Counter = 1
Dim ItemList As Variant

ItemList = shtItemId.Range("A2:A100").Value
ItemList = shtItemId.Application.WorksheetFunction.Transpose( ItemList)
For i = 1 To UBound(ItemList)
If ItemList(i) = ItemId Then
'Set that cell as active cell???
Do
CellQuanValue = ActiveCell.Offset(0, Counter)
Me.Controls("txtQty" & Counter) = CellQuanValue
CellDesValue = ActiveCell.Offset(0, Counter+1)
Me.Controls("txtDes" & Counter) = CellDesValue
Counter = Counter + 1
'UntilNextCellIs Empty???
End If
Next i

Is there is a way to declare that cell as an active cell or an easier
way to to do this?

thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default declaring active cell inside a for loop and offsetting from it

thanks that seems like it will work

but now I am getting an "End If without Block If" Can I run a do loo
inside of a for loop?

heres my code

'Looking in the Sales Order Sheet
For i = 1 To UBound(OrderNum)
tempFlag = 0
If OrderNum(i) = purchase.Value Then 'Filter in Matching Order #
tempFlag = 1
If ItemId(i) = "" Then 'Test for Empty cell
tempFlag = 0
End If
End If

If tempFlag = 1 Then 'Filter out Empty cells
For j = 1 To UBound(ItemList)
If ItemList(j) = ItemId(i) Then
Range("A2:A100")(j).Activate
'Write beginning value for sub assembly
Me.Controls("txtSubQty" & Counter).Enabled
False
Me.Controls("txtQty" & Counter).Enabled = True
Me.Controls("txtSubQty" & Counter).BackColor
&H8000000F

Me.Controls("txtQty" & Counter).Value = Qty(i)
CellDesValue = ActiveCell.Offset(0, 0)
Me.Controls("txtItem" & Counter).Value
CellDesValue
CellDesValue = ActiveCell.Offset(0, 1)
Me.Controls("txtDes" & Counter).Value
CellDesValue
Counter = Counter + 1

Do
CellQuanValue = ActiveCell.Offset(0
SubCounter)
SubCounter = SubCounter + 1
Me.Controls("txtSubQty" & Counter).Enabled
True
Me.Controls("txtQty" & Counter).Enabled
False
Me.Controls("txtQty" & Counter).BackColor
&H8000000F
Me.Controls("txtSubQty" & Counter)
CellQuanValue
CellDesValue = ActiveCell.Offset(0
SubCounter)
Me.Controls("txtDes" & Counter) = CellDesValue
SubCounter = SubCounter + 1
Counter = Counter + 1
While Not IsEmpty(ActiveCell.Offset(0, Counter))
End If
Next j
Me.Controls("txtQty" & Counter).Value = Qty(i)
Me.Controls("txtItem" & Counter).Value = ItemId(i)
Me.Controls("txtDes" & Counter).Value = ItemDes(i)
Me.Controls("txtSubQty" & Counter).Enabled = False
Me.Controls("txtSubQty" & Counter).BackColor
&H8000000F
Counter = Counter + 1
End If
Next

--
Message posted from http://www.ExcelForum.com

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
use time functions inside if loop saedeepu Excel Worksheet Functions 2 September 17th 09 12:55 PM
offsetting Secondary Axes to a cell value [email protected] Charts and Charting in Excel 0 December 28th 06 11:15 PM
Active cell blinks for no reason while running inside of Citrix XP Ed Miller Excel Worksheet Functions 1 January 25th 05 04:53 PM
Offsetting from the Reference of a Cell, not the cell cdegar01 Excel Programming 1 January 20th 04 03:11 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM


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