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

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 341
Default IF else statement

Sub TryThis()

If Sheets("Sheet1").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value = Sheets("Sheet1").Range("B3").Value
Else
If Sheets("Sheet2").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet2").Range("B3").Value
Else
If Sheets("Sheet3").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet3").Range("B3").Value
Else
If Sheets("Sheet4").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet4").Range("B3").Value
End If
End If
End If
End If

End Sub
--
Allllen


" wrote:

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default IF else statement

The OP used ElseIf, so assuming that is wanted

With Sheets("Sheet5").Range("B6")
If Worksheets("Sheet1").Range("B3") < "" Then
.Value = Worksheets("Sheet1").Range("B3").Value
ElseIf Worksheets("Sheet2").Range("B3") < "" Then
.Value = Worksheets("Sheet2").Range("B3").Value
ElseIf Worksheets("Sheet3").Range("B3") < "" Then
.Value = Worksheets("Sheet3").Range("B3").Value
ElseIf Worksheets("Sheet4").Range("B3") < "" Then
.Value = Worksheets("Sheet4").Range("B3").Value
End If
End With



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Allllen" wrote in message
...
Sub TryThis()

If Sheets("Sheet1").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =

Sheets("Sheet1").Range("B3").Value
Else
If Sheets("Sheet2").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet2").Range("B3").Value
Else
If Sheets("Sheet3").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet3").Range("B3").Value
Else
If Sheets("Sheet4").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet4").Range("B3").Value
End If
End If
End If
End If

End Sub
--
Allllen


" wrote:

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 341
Default IF else statement

much neater :-)
--
Allllen


"Bob Phillips" wrote:

The OP used ElseIf, so assuming that is wanted

With Sheets("Sheet5").Range("B6")
If Worksheets("Sheet1").Range("B3") < "" Then
.Value = Worksheets("Sheet1").Range("B3").Value
ElseIf Worksheets("Sheet2").Range("B3") < "" Then
.Value = Worksheets("Sheet2").Range("B3").Value
ElseIf Worksheets("Sheet3").Range("B3") < "" Then
.Value = Worksheets("Sheet3").Range("B3").Value
ElseIf Worksheets("Sheet4").Range("B3") < "" Then
.Value = Worksheets("Sheet4").Range("B3").Value
End If
End With



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Allllen" wrote in message
...
Sub TryThis()

If Sheets("Sheet1").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =

Sheets("Sheet1").Range("B3").Value
Else
If Sheets("Sheet2").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet2").Range("B3").Value
Else
If Sheets("Sheet3").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet3").Range("B3").Value
Else
If Sheets("Sheet4").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet4").Range("B3").Value
End If
End If
End If
End If

End Sub
--
Allllen


" wrote:

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default IF else statement

Many thanks for your help people, but i am still having problems with
this code, I think it may be the sheets.


Allllen wrote:
much neater :-)
--
Allllen


"Bob Phillips" wrote:

The OP used ElseIf, so assuming that is wanted

With Sheets("Sheet5").Range("B6")
If Worksheets("Sheet1").Range("B3") < "" Then
.Value = Worksheets("Sheet1").Range("B3").Value
ElseIf Worksheets("Sheet2").Range("B3") < "" Then
.Value = Worksheets("Sheet2").Range("B3").Value
ElseIf Worksheets("Sheet3").Range("B3") < "" Then
.Value = Worksheets("Sheet3").Range("B3").Value
ElseIf Worksheets("Sheet4").Range("B3") < "" Then
.Value = Worksheets("Sheet4").Range("B3").Value
End If
End With



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Allllen" wrote in message
...
Sub TryThis()

If Sheets("Sheet1").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =

Sheets("Sheet1").Range("B3").Value
Else
If Sheets("Sheet2").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet2").Range("B3").Value
Else
If Sheets("Sheet3").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet3").Range("B3").Value
Else
If Sheets("Sheet4").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet4").Range("B3").Value
End If
End If
End If
End If

End Sub
--
Allllen


" wrote:

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 341
Default IF else statement

A few questions so we can try to help you:

1 - what are your sheets called? Then we can adjust Bob's neat code to fit
your sheet names.

2 - are you sure that you know where you are putting the code? (should be in
a module within the VBE)

3 - if you are getting errors or things aren't happening as you expect, tell
us what you are seeing and what errors you are getting.
--
Allllen


" wrote:

Many thanks for your help people, but i am still having problems with
this code, I think it may be the sheets.


Allllen wrote:
much neater :-)
--
Allllen


"Bob Phillips" wrote:

The OP used ElseIf, so assuming that is wanted

With Sheets("Sheet5").Range("B6")
If Worksheets("Sheet1").Range("B3") < "" Then
.Value = Worksheets("Sheet1").Range("B3").Value
ElseIf Worksheets("Sheet2").Range("B3") < "" Then
.Value = Worksheets("Sheet2").Range("B3").Value
ElseIf Worksheets("Sheet3").Range("B3") < "" Then
.Value = Worksheets("Sheet3").Range("B3").Value
ElseIf Worksheets("Sheet4").Range("B3") < "" Then
.Value = Worksheets("Sheet4").Range("B3").Value
End If
End With



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Allllen" wrote in message
...
Sub TryThis()

If Sheets("Sheet1").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet1").Range("B3").Value
Else
If Sheets("Sheet2").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet2").Range("B3").Value
Else
If Sheets("Sheet3").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet3").Range("B3").Value
Else
If Sheets("Sheet4").Range("B3") < "" Then
Sheets("Sheet5").Range("B6").Value =
Sheets("Sheet4").Range("B3").Value
End If
End If
End If
End If

End Sub
--
Allllen


" wrote:

I am having problem constructing a statement that would copy multiple
cells from different worksheet that display a text output in one cell
of one worksheet.

For example: -

sub

if sheet 1 B3 has text "print in worksheet 5 B6"
end if
else if sheet 2 B3 has text "print in worksheet 5 B6"
end if
else if sheet 3 B3 has text "print in worksheet 5 B6"
end if
else if sheet 4 B3 has text "print in worksheet 5 B6"
end if

END







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 inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
If statement or lookup statement not sure Renegade40 Excel Worksheet Functions 2 January 18th 09 06:11 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


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