Select range based on cell value in a column and copy tranpose.

luzikedy

New Member
Joined
May 23, 2014
Messages
45
Hi there,

I would like to ask you for code that will do the following:

Select range A1:A4 in a sheet "JIN"

Copy Transpose

Move to worksheet "Obsada"

Look for value "1" in a column "W"

Select Range A:D in a row where value "1" was found (There is one value 1 in a sheet in row "W")

Paste transpose from from sheet "Jin"


Thank you in advance!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi,

My understanding is that you want to paste mentioned range in the same row where value 1 is found on sheet "Obsada". Please see code below, I hope it'll work for you:

Code:
Sub CopyTranspose()
Dim Cella
Dim RowID, RowEnd
Application.ScreenUpdating = False
RowID = -1
RowEnd = Sheets("Obsada").UsedRange.Rows.Count
For Each Cella In Sheets("Obsada").Range("w1:w" & RowEnd).Cells
    If Cella.Value = 1 Then
        RowID = Cella.Row
        Sheets("JIN").Range("a1:a4").Copy
        Sheets("Obsada").Cells(RowID, 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
        Application.CutCopyMode = False
        Exit For
    End If
Next Cella
If RowID = -1 Then
    MsgBox "Value 1 not found in column W on sheet 'Obsada'"
    Exit Sub
End If
Application.ScreenUpdating = True
End Sub
Regards,
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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