Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
If statement or lookup statement not sure | Excel Worksheet Functions | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions |