Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default If...then structures

Hi,
I have some code that works fine as is. I now wanted to use it within an If
structure for conditional control. When I try appying my code within an IF
statement it returns nothing i.e no value. myInterest07 picks up a value and
pastes in the worksheet. This no longer works within an If statement. Why?
What am I doing wrong?

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"
If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

myInterest07 = myInterest07 * -1

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default If...then structures

Where is "End If"?

"HeyMickey" wrote in message
...
Hi,
I have some code that works fine as is. I now wanted to use it within an
If
structure for conditional control. When I try appying my code within an IF
statement it returns nothing i.e no value. myInterest07 picks up a value
and
pastes in the worksheet. This no longer works within an If statement. Why?
What am I doing wrong?

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"
If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

myInterest07 = myInterest07 * -1

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default If...then structures

sorry...
macro should read as follows (see below). If the IF part is removed the
macro works fine. I dont understand why myInterest07 does not pick up the
value I am after. Thx.

Sub CollateralKMF()

'finds the adj/collateral value in the MS interest file

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"

If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

'changes the value to negative so we add it up to get net amount

myInterest07 = myInterest07 * -1

'stores the interest figure in the MS sheet

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07

End If

Application.Calculation = xlCalculationAutomatic
Workbooks(myDate & "_interest.csv").Close

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default If...then structures

Where is myFind initailized? I see where you test the value in my find with
your if statement but I do not see where myFind got it's value in the first
place.
--
HTH...

Jim Thomlinson


"HeyMickey" wrote:

Hi,
I have some code that works fine as is. I now wanted to use it within an If
structure for conditional control. When I try appying my code within an IF
statement it returns nothing i.e no value. myInterest07 picks up a value and
pastes in the worksheet. This no longer works within an If statement. Why?
What am I doing wrong?

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"
If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

myInterest07 = myInterest07 * -1

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default If...then structures

Hi Jim,

myFind is a string found when I do this:
Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"

How should I initiliaze correctly myfind?

"Jim Thomlinson" wrote:

Where is myFind initailized? I see where you test the value in my find with
your if statement but I do not see where myFind got it's value in the first
place.
--
HTH...

Jim Thomlinson


"HeyMickey" wrote:

Hi,
I have some code that works fine as is. I now wanted to use it within an If
structure for conditional control. When I try appying my code within an IF
statement it returns nothing i.e no value. myInterest07 picks up a value and
pastes in the worksheet. This no longer works within an If statement. Why?
What am I doing wrong?

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"
If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

myInterest07 = myInterest07 * -1

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default If...then structures

Is it that myFind isn't getting set, so the IF is always False?

--
HTH

Bob Phillips

"HeyMickey" wrote in message
...
Hi,
I have some code that works fine as is. I now wanted to use it within an

If
structure for conditional control. When I try appying my code within an IF
statement it returns nothing i.e no value. myInterest07 picks up a value

and
pastes in the worksheet. This no longer works within an If statement. Why?
What am I doing wrong?

Dim mySDate As String
Dim myDate As String
Dim myInterest07 As Double
Dim myRow As Long
Dim sPath As String
Dim myFind As String



myDate = Format(InputBox("Please enter date for input files (dd/mm/yy)", ,
"11/04/05"), "dd/mm/yy")
mySDate = Format(myDate, "mm-dd-yy")
myDate = Format(myDate, "yyyymmdd")
Workbooks.Open FileName:=sPath & myDate & "_interest.csv"

Columns("A:A").Insert Shift:=xlToRight
range("A1:A2149").FormulaR1C1 = "=CONCATENATE(RC[1],RC[4])"
If myFind = "04F641007USD" Then
myInterest07 = Cells.Find(What:=myFind, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Offset(0, 9)

myInterest07 = myInterest07 * -1

Workbooks("Testmsinput.xls").Worksheets("MS Input3").Cells(11, 4).Value =
myInterest07




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 do I draw chemical structures in Excel spreed sheet? James Charts and Charting in Excel 1 March 31st 09 08:29 AM
Importing File Structures to Excel asummers Excel Discussion (Misc queries) 3 February 23rd 06 01:42 PM
Useing Class structures and Events Dan Gardner Excel Programming 2 January 13th 05 08:43 AM


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