LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
dan dan is offline
external usenet poster
 
Posts: 866
Default MACRO HELP, PASTE CELL TO COLUMN

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO PASTE CELL to COLUMN, SKIP ROWS Dan Excel Discussion (Misc queries) 1 February 2nd 10 01:03 PM
macro that will paste a number in first blank cell of a column asebes Excel Discussion (Misc queries) 1 December 28th 09 05:34 PM
Macro-continue to paste last column puiuluipui Excel Discussion (Misc queries) 0 September 24th 09 10:02 PM
A macro to copy & paste many rows (a range) to the next column .. genehunter New Users to Excel 11 April 21st 09 07:36 AM
How to set macro to Paste Special Value to next empty column [email protected] Excel Worksheet Functions 9 May 5th 08 11:57 PM


All times are GMT +1. The time now is 11:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"