Copy cell Next from Cell with Text "True"

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
I need a Vba Code to control if one of those cell is "True"
i have try with this code but it aint work


Code:
Sub Copypast()'
' Copypast Makro


If Sheets("Copy").Range("D5").Text = "True" Then


    Sheets("Copy").Select
    Range("E5").Select
    Selection.Copy
    Sheets("Past").Select
    Range("G2").Select
    ActiveSheet.Paste
    End If
End Sub

So help Need
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
How is it not working?

Try
Code:
Sub copypast()
If UCase(Sheets("copy").Range("D5")) = "TRUE" Then
    Sheets("past").Range("G2") = Sheets("copy").Range("D5")

End If

End Sub
 
Upvote 0
Hi,
try

Code:
Sub copypast()
    Dim rng As Range
    Set rng = Sheets("copy").Range("D5")
    If CBool(rng.Value) Then Sheets("past").Range("G2") = rng.Offset(, 1)
End Sub

Dave
 
Upvote 0
Or maybe
Code:
Sub Copypast() '
' Copypast Makro

With Sheets("Copy")
   If .Range("D5").Value = True Then
      .Range("E5").Copy Sheets("Past").Range("G2")
   End If
End With
End Sub
 
Upvote 0
try
Code:
Sub Copypast()

Dim lastRow As Long
Dim i       As Long
Dim p       As Long
Dim ccSheet As Worksheet
Dim paSheet As Worksheet


lastRow = Sheets("Copy").Range("D" & Rows.Count).End(xlUp).Row
Set ccSheet = Sheets("Copy")
Set paSheet = Sheets("Past")

    p = 1
For i = 2 To lastRow
    
If Sheets("Copy").Range("D" & i).Value = True Then
    p = p + 1
ccSheet.Range("E" & i).Copy paSheet.Range("G" & p)
End If
Next i
End Sub

Note: that "True" needs to be in all caps as this is case sensitive or change "TRUE" to whatever case you want.
Sheets must be named "Copy" and "Past"

EDIT:
I don't know if you needed to loop through columns as you did not specify. if not:
Fluff strikes again, his is better use that.
 
Last edited:
Upvote 0
It was Blakskate code there was the winner

Thank you So Much for the code It works like a Brilliant Diamond

And thanks to all for help
 
Upvote 0
Dear BlakeSkate i run your code and ran into a Minor Problem

All the cell your code Copy and Past Didn "Copy Or Past" right.

the Last 16 cell's there where Looking for "TRUE" on "D" is ok, But when Copy From cell's in Colomn "E264" to "E307"
the cell value AInt Appear on Sheet Past the only Value/Text there is entered is"formula" with Error on Refference's
is it possibel to make it work :_)


and i have to Put a Feature in you code because the Copy Take all in cell and past it

Code:
Sub Copypast()

Dim lastRow As Long
Dim i       As Long
Dim p       As Long
Dim ccSheet As Worksheet
Dim paSheet As Worksheet




lastRow = Sheets("Cup 128").Range("D" & Rows.Count).End(xlUp).Row
Set ccSheet = Sheets("Cup 128")
Set paSheet = Sheets("Matchlist")


    p = 1
For i = 2 To lastRow
    
If Sheets("Cup 128").Range("D" & i).Value = True Then
    p = p + 1
ccSheet.Range("E" & i).Copy paSheet.Range("G" & p)
End If
Next i
[COLOR=#ff0000]Range("G2:G33").Select[/COLOR]
[COLOR=#ff0000]    With Selection.Font[/COLOR]
[COLOR=#ff0000]        .Name = "Calibri"[/COLOR]
[COLOR=#ff0000]        .Size = 14[/COLOR]
[COLOR=#ff0000]        .Strikethrough = False[/COLOR]
[COLOR=#ff0000]        .Superscript = False[/COLOR]
[COLOR=#ff0000]        .Subscript = False[/COLOR]
[COLOR=#ff0000]        .OutlineFont = False[/COLOR]
[COLOR=#ff0000]        .Shadow = False[/COLOR]
[COLOR=#ff0000]        .Underline = xlUnderlineStyleNone[/COLOR]
[COLOR=#ff0000]        .ThemeColor = xlThemeColorLight1[/COLOR]
[COLOR=#ff0000]        .TintAndShade = 0[/COLOR]
[COLOR=#ff0000]        .ThemeFont = xlThemeFontMinor[/COLOR]
[COLOR=#ff0000]    End With[/COLOR]
[COLOR=#ff0000]    Columns("G:G").Select[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlDiagonalDown).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlDiagonalUp).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlEdgeLeft).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlEdgeTop).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlEdgeBottom).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlEdgeRight).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlInsideVertical).LineStyle = xlNone[/COLOR]
[COLOR=#ff0000]    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone[/COLOR]
End Sub
 
Upvote 0
the only Value/Text there is entered is"formula" with Error on Refference's

Do you want to keep the formula or have it copy the value of the formula? if you're moving the formula and it references to anything on the same sheet the formula will have to be changed i believe. also its kind of hard to visualize without a copy of your workbook if possible could you provide a dropbox link or similar method (you can change any sensitive information to random numbers and letters)?
 
Upvote 0
try changing

Code:
ccSheet.Range("E" & i).Copy paSheet.Range("G" & p)

to

Code:
paSheet.Range("G" & p).Value = ccSheet.Range("E" & i).Value

I'm not able to test this at this moment but i believe thats the solution

<colgroup><col width="89"></colgroup><tbody>
[TD="width: 89, align: right"][/TD]

</tbody>
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top