Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Cell Referencing in VBA

hi - Need help with understanding hwo to return a cell reference based on
values in the cell...here are some details...any help would be absolutely
appreciated.

User Input Form

Type Name Rev $ No of Stores State
Retail Reece 12 300 VIC
Retail Big W 1222 212 NSW
Retail JB 1212 232 SA
Retail Target 3234 343 WA

Database Table
Type Name Rev $ No of Stores State
Retail Reece C2 D2 C2
Retail Big W C3 D3 C3
Retail JB C4 D4 C4
Retail Target C5 D5 C5

RowCount (needs to look up the database table which has Company Type and
House Name and match this to what the userform has and get the rowcount to
point to a cell reference C2 when Company Type = "Retail" And Company Name =
"Reece"

Once i can get that cell reference i can then use offset to place the output
from userform to the table

..Offset(RowCount, 3).Value = Me.Rev$.Value
..Offset(RowCount, 4).Value = Me.NoOfStores.Value
..Offset(RowCount, 5).Value = Me.State.Value

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Cell Referencing in VBA

Because you have a double lookup I like to make my own search macro

InputRowCount = 2 ' skip header
DatabaseRowCount = 2 ' skip header
with sheets("Input form")
do while .Range("A" & InputRowCount) < ""
Mytype = .Range("A" & InputRowCount)
Myname = .Range("A" & InputRowCount)
with sheets("Database table")
found = false
do while .Range("A" & DatabaseRowCount) < ""
if MyType = .Range("A" & DatabaseRowCount) and _
MyName = .Range("B" & DatabaseRowCount) then

found = true
exit do

end if
DatabaseRowCount = DatabaseRowCount + 1
loop
end with
if found = true then
'enter your code here
end if
InputRowCount = InputRowCount + 1
loop

end with


"amit" wrote:

hi - Need help with understanding hwo to return a cell reference based on
values in the cell...here are some details...any help would be absolutely
appreciated.

User Input Form

Type Name Rev $ No of Stores State
Retail Reece 12 300 VIC
Retail Big W 1222 212 NSW
Retail JB 1212 232 SA
Retail Target 3234 343 WA

Database Table
Type Name Rev $ No of Stores State
Retail Reece C2 D2 C2
Retail Big W C3 D3 C3
Retail JB C4 D4 C4
Retail Target C5 D5 C5

RowCount (needs to look up the database table which has Company Type and
House Name and match this to what the userform has and get the rowcount to
point to a cell reference C2 when Company Type = "Retail" And Company Name =
"Reece"

Once i can get that cell reference i can then use offset to place the output
from userform to the table

.Offset(RowCount, 3).Value = Me.Rev$.Value
.Offset(RowCount, 4).Value = Me.NoOfStores.Value
.Offset(RowCount, 5).Value = Me.State.Value

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Cell Referencing in VBA

hi Joel - Thx a lot for this......only one issue was that i wasnt clear in my
earliar note....the user input was from a user form with combo n text
boxes....and u'r code assumed it was from a sheet......

but i have worked this out and now my code uses the user entries in the
userform as the input for the search code....

thanks again.....



"Joel" wrote:

Because you have a double lookup I like to make my own search macro

InputRowCount = 2 ' skip header
DatabaseRowCount = 2 ' skip header
with sheets("Input form")
do while .Range("A" & InputRowCount) < ""
Mytype = .Range("A" & InputRowCount)
Myname = .Range("A" & InputRowCount)
with sheets("Database table")
found = false
do while .Range("A" & DatabaseRowCount) < ""
if MyType = .Range("A" & DatabaseRowCount) and _
MyName = .Range("B" & DatabaseRowCount) then

found = true
exit do

end if
DatabaseRowCount = DatabaseRowCount + 1
loop
end with
if found = true then
'enter your code here
end if
InputRowCount = InputRowCount + 1
loop

end with


"amit" wrote:

hi - Need help with understanding hwo to return a cell reference based on
values in the cell...here are some details...any help would be absolutely
appreciated.

User Input Form

Type Name Rev $ No of Stores State
Retail Reece 12 300 VIC
Retail Big W 1222 212 NSW
Retail JB 1212 232 SA
Retail Target 3234 343 WA

Database Table
Type Name Rev $ No of Stores State
Retail Reece C2 D2 C2
Retail Big W C3 D3 C3
Retail JB C4 D4 C4
Retail Target C5 D5 C5

RowCount (needs to look up the database table which has Company Type and
House Name and match this to what the userform has and get the rowcount to
point to a cell reference C2 when Company Type = "Retail" And Company Name =
"Reece"

Once i can get that cell reference i can then use offset to place the output
from userform to the table

.Offset(RowCount, 3).Value = Me.Rev$.Value
.Offset(RowCount, 4).Value = Me.NoOfStores.Value
.Offset(RowCount, 5).Value = Me.State.Value

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
Cell Referencing Kris W[_2_] Excel Worksheet Functions 5 August 27th 09 01:45 AM
Referencing Last Cell jlo Excel Worksheet Functions 8 September 4th 08 09:06 PM
Referencing Cell Next To Today's Date Cell Docktondad Excel Discussion (Misc queries) 5 May 16th 07 10:25 PM
Obtain Cell Formatting in Cell Referencing? Al Franz Excel Programming 1 April 22nd 07 10:51 PM
Cell referencing ED Excel Programming 3 July 23rd 04 11:23 PM


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