Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help in Excel VBA for simple task

I'm a VB programmer and now I was asked to do a simple task in Excel
using VBA. And I only have 2 days to do it. Can someone tell me how
to:

Search a given range in SheetA, look for ItemA (from column A) and
insert the data from SheetA's column B into SheetB's column B?
Additonal criteria would be, SheetA's column C should match the
filtering criteria obtain from SheetB's cell C1 and SheetA's ItemA
should match SheetB's column B, for example.

SheetA
ColA ColB ColC
A001 1000 2
A002 1200 2
A003 900 1
A004 1300 2

SheetB should shows (provided cell C1 = 2):
ColA ColB
A001 1000
A002 1200
A004 1300

I'm really in a rush for this task because this task is the 1st stage
in order to proceed to my later stages in my VB project development.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Help in Excel VBA for simple task

Look up Find in Excel VBA help, that shows how to find a value in the
column.

Then just offset the found cell by 1 column, cell.Offset(0,1).Value to get
B's value.

Don't understand the C bit.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jani" wrote in message
oups.com...
I'm a VB programmer and now I was asked to do a simple task in Excel
using VBA. And I only have 2 days to do it. Can someone tell me how
to:

Search a given range in SheetA, look for ItemA (from column A) and
insert the data from SheetA's column B into SheetB's column B?
Additonal criteria would be, SheetA's column C should match the
filtering criteria obtain from SheetB's cell C1 and SheetA's ItemA
should match SheetB's column B, for example.

SheetA
ColA ColB ColC
A001 1000 2
A002 1200 2
A003 900 1
A004 1300 2

SheetB should shows (provided cell C1 = 2):
ColA ColB
A001 1000
A002 1200
A004 1300

I'm really in a rush for this task because this task is the 1st stage
in order to proceed to my later stages in my VB project development.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help in Excel VBA for simple task

wasn't sure exactly whatt you wanted from your description. this shoudl get
you started. Post response if you need more help

Sub MyLookup()

'search column a sheet a
Sheets("SheetA").Activate
'rows.count is a constant indicating last row in worksheet
'end(xlup) search from end of worksheet to 1st non-empty cell
ShALastRow = Cells(Rows.Count, 1).End(xlUp).Row
Set ShAColARange = Sheets("SheetA").Range(Cells(1, 1), Cells(ShALastRow, 1))

Sheets("SheetB").Activate
'rows.count is a constant indicating last row in worksheet
'end(xlup) search from end of worksheet to 1st non-empty cell
ShBLastRow = Cells(Rows.Count, 1).End(xlUp).Row
Set ShBColARange = Sheets("SheetB").Range(Cells(1, 1), Cells(ShBLastRow, 1))

For Each MyCell In ShAColARange
If Not IsEmpty(MyCell) Then
Sheets("SheetB").Activate
Set FoundCell = _
ShBColARange.Find(MyCell, LookIn:=xlValues)

If Not FoundCell Is Nothing Then
'insert the data from SheetA's column B into SheetB's column B
FoundCell.Offset(rowoffset:=0, columnoffset:=1) = _
MyCell.Offset(rowoffset:=0, columnoffset:=1)

'SheetA 's column C should match the filtering criteria
'obtain from SheetB's cell C1
MyCell.Offset(rowoffset:=0, columnoffset:=2) = _
Sheets("SheetB").Range("C1")

End If
End If

Next MyCell

End Sub


"Jani" wrote:

I'm a VB programmer and now I was asked to do a simple task in Excel
using VBA. And I only have 2 days to do it. Can someone tell me how
to:

Search a given range in SheetA, look for ItemA (from column A) and
insert the data from SheetA's column B into SheetB's column B?
Additonal criteria would be, SheetA's column C should match the
filtering criteria obtain from SheetB's cell C1 and SheetA's ItemA
should match SheetB's column B, for example.

SheetA
ColA ColB ColC
A001 1000 2
A002 1200 2
A003 900 1
A004 1300 2

SheetB should shows (provided cell C1 = 2):
ColA ColB
A001 1000
A002 1200
A004 1300

I'm really in a rush for this task because this task is the 1st stage
in order to proceed to my later stages in my VB project development.


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
How to automatize this simple task on Excel? [email protected] Excel Worksheet Functions 1 April 13th 08 08:43 AM
How to automatize this simple task on Excel? [email protected] Excel Discussion (Misc queries) 2 April 13th 08 08:18 AM
Help needed in a simple task vmantrana Excel Discussion (Misc queries) 3 April 18th 06 12:57 AM
Question about Simple task aksama New Users to Excel 1 January 2nd 06 03:37 AM
Not-so-simple Find task Mark Tangard Excel Programming 2 September 9th 03 01:33 PM


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