Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Code for Selective formula writing


I need to write some VBA code which will write formula into several row
- however, I want it to select which rows it writes the code int
depending upon the following

Sheet1

(Row Number) ID Price
1 1234 (Formula which will be written if applicable)
2 4321 (Formula which will be written if applicable)
3 5678 (Formula which will be written if applicable)


Sheet2
ID
1234

In this case, I would only want to write the formula into line 1 i
sheet1.

is this possible? maybe an If statement or something or a For Each Row
= 1 to X????
Cheers

--
Fuerteventur
-----------------------------------------------------------------------
Fuerteventura's Profile: http://www.excelforum.com/member.php...fo&userid=2658
View this thread: http://www.excelforum.com/showthread.php?threadid=39856

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default VBA Code for Selective formula writing

Fuerteventura,

Dim myCell As Range
For Each myCell In Worksheets("Sheet1").Range("A2:A4")
If Not (IsError(Application.Match(myCell.Value, _
Worksheets("Sheet2").Range("A:A"), False))) Then
myCell(1, 2).Formula = "=Formula which will be written....."
End If
Next myCell

Or you could just use an if formula in all the cells, that returns "" when the value isn't found....

HTH,
Bernie
MS Excel MVP


"Fuerteventura" wrote in message
news:Fuerteventura.1u9s2i_1124888738.4429@excelfor um-nospam.com...

I need to write some VBA code which will write formula into several rows
- however, I want it to select which rows it writes the code into
depending upon the following

Sheet1

(Row Number) ID Price
1 1234 (Formula which will be written if applicable)
2 4321 (Formula which will be written if applicable)
3 5678 (Formula which will be written if applicable)


Sheet2
ID
1234

In this case, I would only want to write the formula into line 1 in
sheet1.

is this possible? maybe an If statement or something or a For Each Rows
= 1 to X????
Cheers.


--
Fuerteventura
------------------------------------------------------------------------
Fuerteventura's Profile: http://www.excelforum.com/member.php...o&userid=26586
View this thread: http://www.excelforum.com/showthread...hreadid=398560



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
Selective formula AleVe Excel Discussion (Misc queries) 5 March 3rd 10 05:39 PM
Need help writing Code LeAnne Excel Discussion (Misc queries) 1 February 15th 08 03:27 PM
Need some help writing code. Erik[_6_] Excel Programming 5 February 29th 04 06:51 PM
Code writing:Where to start ? MIke Excel Programming 2 February 19th 04 08:46 PM
Writing a formula in code Tom Ogilvy Excel Programming 0 September 5th 03 02:32 PM


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