Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question in a function cell to cell

Hello,

I have a question about VBA in Excel. I received from Access of the
data that I insert in Excel. I use a formula with a IF like below. I
place it in the B24 cell then I recopy it in an automatic way to cell
IV24 but I cannot use in IF for saying if I have anything, I do
anything if not make calculation and frames the cell by a border.

Code:
--------------------------------------------------------------------------------

IF(B5="";"";b14*100/b22)
--------------------------------------------------------------------------------



How to do in VBA this:
I place myself in the B24 cell, If B5 and empty then I do anything if
not I make B14*100/B22 and I put a border at my cell then I shift of a
cell, I place myself in C24 and if C5 is empty I do anything if not I
make C14*100/C22 then I frame my cell and so on.

I would like to make a procedure which automatically starts reception
of the data of Access.

Could you help me on this problem.

Keawee



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question in a function cell to cell

Will this work for you? You can also choose appropriate
variable names to replace the hardcoded rows I used.

Sub Macro1()
Dim iColumn As Integer
Dim iMaxCol As Integer
Dim lCalc As Long

iColumn = 2
iMaxCol = Range("IV1").Column
Do Until iColumn iMaxCol
If Cells(5, iColumn).Value < "" Then
If Cells(22, iColumn).Value = 0 Then
Cells(24, iColumn).Value = 0
Else
lCalc = Cells(14, iColumn).Value * 100
lCalc = lCalc / Cells(22, iColumn).Value
Cells(24, iColumn).Value = lCalc
End If
Cells(24, iColumn).Select
Call DrawLine(xlEdgeLeft)
Call DrawLine(xlEdgeTop)
Call DrawLine(xlEdgeBottom)
Call DrawLine(xlEdgeRight)
End If
iColumn = iColumn + 1
Loop
End Sub

Sub DrawLine(aEdge)
With Selection.Borders(aEdge)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub



-----Original Message-----
Hello,

I have a question about VBA in Excel. I received from

Access of the
data that I insert in Excel. I use a formula with a IF

like below. I
place it in the B24 cell then I recopy it in an automatic

way to cell
IV24 but I cannot use in IF for saying if I have

anything, I do
anything if not make calculation and frames the cell by a

border.

Code:
----------------------------------------------------------

----------------------

IF(B5="";"";b14*100/b22)
----------------------------------------------------------

----------------------



How to do in VBA this:
I place myself in the B24 cell, If B5 and empty then I do

anything if
not I make B14*100/B22 and I put a border at my cell then

I shift of a
cell, I place myself in C24 and if C5 is empty I do

anything if not I
make C14*100/C22 then I frame my cell and so on.

I would like to make a procedure which automatically

starts reception
of the data of Access.

Could you help me on this problem.

Keawee



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question in a function cell to cell

Hi keawee,

You can try this:

Sub YesNoCalc()
On Error goto ErrInProcedure

Dim c As Integer

For c = 2 To 256

If Cells(5, c) < "" Then
Cells(24, c) = (Cells(14, c) * 100) / (Cells(22, c))
Cells(24, c).Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End If

Next c

Exit sub

ErrInProcedu
MsgBox Err.Description


End Sub


You must make sure that Row 22 contains a number greater than zero,
else you will get an error.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly 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
Conditional Formatting question (if cell = 0, wrap cell in quotes) Mo2 New Users to Excel 6 May 11th 07 11:06 PM
copying the function contained within a cell to anouther cell. DMB Excel Worksheet Functions 2 September 1st 05 05:49 PM
function CELL() to return the formula in the referenced cell Streep Excel Worksheet Functions 3 August 20th 05 10:24 PM
Function to determine if any cell in a range is contained in a given cell [email protected] Excel Worksheet Functions 3 February 7th 05 04:19 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 11:00 PM.

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"