formula needed

kylefoley76

Well-known Member
Joined
Mar 1, 2010
Messages
1,553
I need a macro where if a 1 appears in column B, the copy what is in column A into the next blank column in column C.

Note: a 1 in column B will appear sporadically but in column C I need each row to be filled one after the other. So in column B many rows will be empty but no rows in column C will be empty.
Thanks in advance.
 
i don't have windows. so that line window(thatfile) will have to be deleted

plus on thisfile, it needs to be sheet 2. i don't anywhere in that macro that specifies sheet 2

Try this. I believe the "windows" line isn't specific to the OS.

Code:
Sub FindTheOne()
Dim LR As Long
Dim i As Long
Dim thisFile As String
Dim thatFile As String
Dim Temp

thisFile = ActiveWorkbook.Name
thatFile = "Time.xlms"

Windows(thatFile).Activate
    Sheets(1).Select
    LR = Range("K" & Rows.Count).End(xlUp).Row
    
    For i = 1 To LR
        If Range("I" & i) = 1 Then
            Temp = Range("A" & i)
            Windows(thisFile).Activate
                Sheets(2).Select
                Range("A" & Range("A" & Rows.Count).End(xlUp).Row + 1) = Temp
            Windows(thatFile).Activate
        End If
    Next i

End Sub
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
yes i fixed the typo. isn't there some way around this problem. can't we do it the old fashioned way of just naming the document like they do in formulas? i've never seen this method of naming docs the way you do. how do other people do it?
 
Upvote 0
Record a new macro that toggles between 2 open files and see what it uses instead of Windows(xxxx).Activate.
 
Upvote 0
here's what it uses

ActiveCell.FormulaR1C1 = "2"
Range("E162").Select
Windows("time.xlsm").Activate
ActiveCell.FormulaR1C1 = "1/4/1904 12:00:00 AM"
Range("F7252").Select
Selection.Copy
Windows("charts.xlsm").Activate
ActiveSheet.Paste
Range("E163").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=[time.xlsm]time!R7255C11"
Range("E164").Select

i can't figure out why there's a buy in that macro you wrote
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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