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


I am making a macro to copy data from a cell in one workbook and pastin
it into another workbook. Unfortunatly I don't know VB too well, I'
more use to writing formulas in excel cells.

I'm trying to write an IF, THEN, ELSE statement in which the progra
will not display a cells contents if there is nothing to display (blan
cell). I do most of my programs in excel rather than VB. This is wha
I would put in excel to do what im looking to do: If(A1="","",A1).
How do I go about doing that in VB? Here is what I have so far, I'
just working around it by telling the program to display the results i
a different cell, but its not working as planned, and I need the progra
to just not display the info anywhere.

Dim NTHNG As String
Dim TFR1 As String

NTHNG = Range("GL19").Value
TFL1 = Range("BK12").Value

If TFL1 = "" Then .Cells(3, 115).Value = NTHNG Else .Cells(12
63).Value = TFL1

Any help would be appreciated

Da

--
dl
-----------------------------------------------------------------------
dlb's Profile: http://www.excelforum.com/member.php...fo&userid=1648
View this thread: http://www.excelforum.com/showthread.php?threadid=51243

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default If statement question

Does this not work?


If TFL1 = "" Then
.Cells(3, 115).Value = Range("GL19").Value
Else
.Cells(12,63).Value = Range("BK12").Value
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"dlb" wrote in message
...

I am making a macro to copy data from a cell in one workbook and pasting
it into another workbook. Unfortunatly I don't know VB too well, I'm
more use to writing formulas in excel cells.

I'm trying to write an IF, THEN, ELSE statement in which the program
will not display a cells contents if there is nothing to display (blank
cell). I do most of my programs in excel rather than VB. This is what
I would put in excel to do what im looking to do: If(A1="","",A1).
How do I go about doing that in VB? Here is what I have so far, I'm
just working around it by telling the program to display the results in
a different cell, but its not working as planned, and I need the program
to just not display the info anywhere.

Dim NTHNG As String
Dim TFR1 As String

NTHNG = Range("GL19").Value
TFL1 = Range("BK12").Value

If TFL1 = "" Then .Cells(3, 115).Value = NTHNG Else .Cells(12,
63).Value = TFL1

Any help would be appreciated

Dan


--
dlb
------------------------------------------------------------------------
dlb's Profile:

http://www.excelforum.com/member.php...o&userid=16483
View this thread: http://www.excelforum.com/showthread...hreadid=512432



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If statement question


The NTHNG cell has an "X" in it, even if I keep the cell blank, it won't
work. The workbook I'm pasting into is protected, but the cell is
unprotected, and that cell is referenced in a formula that can only
read numbers, or blank cells, and for some reason even if I paste a
blank cell into it, it reads that as something rather than nothing, and
it causes an error in the formula.

Basically I'm trying to find out how to write an IF statement that will
not do anything if the cell is blank. Is that possible? Or is there
another way of doing this?

Dan


--
dlb
------------------------------------------------------------------------
dlb's Profile: http://www.excelforum.com/member.php...o&userid=16483
View this thread: http://www.excelforum.com/showthread...hreadid=512432

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If statement question


still having some troubles w/ this


--
dlb
------------------------------------------------------------------------
dlb's Profile: http://www.excelforum.com/member.php...o&userid=16483
View this thread: http://www.excelforum.com/showthread...hreadid=512432

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If statement question


any ideas

--
dl
-----------------------------------------------------------------------
dlb's Profile: http://www.excelforum.com/member.php...fo&userid=1648
View this thread: http://www.excelforum.com/showthread.php?threadid=51243



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If statement question


It seems to me that Bob gave you a good start, but if I am reading what
you are asking right, I thing the code might be more like this:


Code:
--------------------
If TFL1 = "" Then
'do nothing
Else
'insert the code for whatever it is you want it to do if there is something.
--------------------


Of course I am a little unclear as to what you are actually trying to
accomplish, but then again that is not uncommon around here.

I don't know if that will help you at all, but whenever I am using an
IF statement in code, and one of the options of the if is when I want
it to do nothing, I just stick in the comment line " 'do nothing"
instead of trying to code for contingencies I can't even possibly guess
at.

Here's to hope, and take care,
Amber :)

Bob Phillips Wrote:
Does this not work?


If TFL1 = "" Then
.Cells(3, 115).Value = Range("GL19").Value
Else
.Cells(12,63).Value = Range("BK12").Value
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"dlb" wrote in
message
...

I am making a macro to copy data from a cell in one workbook and

pasting
it into another workbook. Unfortunatly I don't know VB too well,

I'm
more use to writing formulas in excel cells.

I'm trying to write an IF, THEN, ELSE statement in which the program
will not display a cells contents if there is nothing to display

(blank
cell). I do most of my programs in excel rather than VB. This is

what
I would put in excel to do what im looking to do: If(A1="","",A1).
How do I go about doing that in VB? Here is what I have so far, I'm
just working around it by telling the program to display the results

in
a different cell, but its not working as planned, and I need the

program
to just not display the info anywhere.

Dim NTHNG As String
Dim TFR1 As String

NTHNG = Range("GL19").Value
TFL1 = Range("BK12").Value

If TFL1 = "" Then .Cells(3, 115).Value = NTHNG Else .Cells(12,
63).Value = TFL1

Any help would be appreciated

Dan


--
dlb

------------------------------------------------------------------------
dlb's Profile:

http://www.excelforum.com/member.php...o&userid=16483
View this thread:

http://www.excelforum.com/showthread...hreadid=512432



--
Amber_D_Laws
------------------------------------------------------------------------
Amber_D_Laws's Profile: http://www.excelforum.com/member.php...o&userid=30012
View this thread: http://www.excelforum.com/showthread...hreadid=512432

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
IF Statement question peg84 Excel Discussion (Misc queries) 3 February 4th 08 10:19 PM
IF statement question [email protected] Excel Worksheet Functions 2 July 24th 06 04:20 PM
IF then statement question ChuckW Excel Discussion (Misc queries) 2 February 24th 06 04:30 PM
Question about dim statement Gregg[_4_] Excel Programming 4 July 19th 05 03:07 PM
If Statement Question carl Excel Worksheet Functions 1 March 11th 05 04:55 AM


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