Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy between workbooks if statement is true

I have two workbooks: Prisliste.xls (price list) and faktura.xls (invoice).
In the invoice I want to just write id-numbers, and based on these
id-numbers, I want a macro to get the data from the price list.

In Prisliste.xls I have the following data:
Column A: id-number
Column B: name of book
Column D: price of book
Column E: price of book ex. taxes

In faktura.xls I have an area (cell B19 to D32), where I want the data
transferred. Names of books in column B, prices in column D.

I want to write id-numbers in the cells of column B, run a macro that
replaces the numbers with names, and inserts the prices.

How do I make the macro understand where to put the names and the prices?
What should I write instead of ActiveSheet.Range("B") ?

This is my code so far (I might be far off, or close to the solution):

Sub boknummer()

'nameing the area in use "tittel"
Dim tittel As Range
Set tittel = Range("B19:B32")

For Each Cell In tittel

If Cell.Value =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("A2").Value Then
'checks if the id-number is the same as the first id-number of Prisliste.xls
ActiveSheet.Range("B") =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("B2").Value 'inserts
the book name
ActiveSheet.Range("D") =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("D2").Value 'inserts
the book price
End If

'checks the next id-number

If Cell.Value =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("A3").Value Then
ActiveSheet.Range("B") =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("B3").Value
ActiveSheet.Range("D") =
Workbooks("Prisliste.xls").Worksheets("priser").Ra nge("E3").Value
End If

'checks the other id-numbers, I excluded the code since it is
similar to the examples above.

Next

End Sub


Thanks for any suggestions, links etc

Ingeborg Altern Vedal


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
TRUE/FALSE STATEMENT Dave Excel Discussion (Misc queries) 4 September 1st 09 11:55 AM
copy an entire row IF a statement is true colettey29 Excel Worksheet Functions 1 June 15th 07 06:43 PM
Two TRUE to one FALSE statement bluebird Excel Worksheet Functions 4 January 11th 07 04:07 PM
If then statement with two true conditions Don Guillett[_4_] Excel Programming 0 October 16th 04 12:01 AM
if statement is true, copy data to another location janco tianno Excel Programming 2 June 30th 04 09:37 PM


All times are GMT +1. The time now is 07:19 AM.

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"