Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
hi, i am trying to improve on a macro to paste a cell down a column.
with an updated cell at top with a formula, i do a cntrl-c & pick the top row of the column i want to start pasting at (any column i select). should skip rows where column A has a period "." improvement needs to copy to ALL cells at the same time.. instead of 1 cell at a time. thanks in advance i have a couple of examples below, the 1st does all of above, but only does 1 cell at a time. 2nd does not skip rows, 3rd is an alternate idea, not familiar with macro 1 i want to manually copy new formula from 1 cell at top, 2 manually select any column, 'dynamic' range of rows, or end row.. (i will manually select 1st cell/ row in col desired for paste col), 3 paste formula's, skip rows where col A has a period "." 1ST EXAMPLE: Sub PastecellE() 'alt-E (paste cell eq/ formula) r = ActiveCell.Row 'row c = ActiveCell.Column 'cell LastRow = Range("C4").Value 'C4 has: =ROW($A$2058) 'last row For Each c In Range(Cells(r, c), Cells(LastRow, c)) If Cells(c.Row, "A").Value < "." Then c.Select Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End If Next c End Sub XXXXXXXXXXXXXXX 2nd example, does not skip rows Sub test() 'alt-T (test) Dim C4 As String C4 = Range("C4") 'C4 has: =ROW($A$2058)-ROW($A$228)-1 'range of rows Range(ActiveCell, ActiveCell.Offset(C4, 0)).Select Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End Sub XXXXXXXXXXXXXXX 3rd example Sub test() 'alt-T (test), does not work/ as is, 'not sure if will do what want: testing Dim cell As Range Dim ws As Worksheet Dim C4 As Long 'this is a number since using it as an offset Set ws = Worksheets("sym") ' Set ws = Worksheets("Sheet1") C4 = ws.Range("C4").Value 'C4 has: =ROW($A$2058)-ROW($A$228)-1 'ERROR For Each cell In ws.Range(C4) '(err: METHOD RANGE OF OBJECT WORKSHEET FAILED) 'column manual selected / rows C4 If ws.Range("A" & cell.Row).Value = "." Then 'do nothing Else 'PROBLEM: With ws.Range(ActiveCell, ws.Range(ActiveCell, ActiveCell & cell.Row).Offset(C4, 0)) 'MODIFY 'With ws.Range("A" & cell.Row, ws.Range("A" & cell.Row).Offset(C4, 0)) 'WRONG, not just col A 'Range(ActiveCell, ActiveCell.Offset(C4, 0)).Select 'ORIGINAL WORKS (in above) PASTE ALL ROWS: NOT WANTED .PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End With End If Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MACRO PASTE CELL to COLUMN, SKIP ROWS | Excel Discussion (Misc queries) | |||
macro that will paste a number in first blank cell of a column | Excel Discussion (Misc queries) | |||
Macro-continue to paste last column | Excel Discussion (Misc queries) | |||
A macro to copy & paste many rows (a range) to the next column .. | New Users to Excel | |||
How to set macro to Paste Special Value to next empty column | Excel Worksheet Functions |