Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have worksheet 1 that has some data in a column. I want to copy this
data in to another worksheet 2 that starts on column 4, row 5, but only the first 4 characters of the data should be put in this cell....and then I want to have it run in a loop so that it copies the entire column from worksheet 1 to worksheet 2 in that same fashion (same column, but increments the row)....How do I do that? Also, how do I clear out a range of data that starts at B4 and then goes down the column? Any help would be appreciated!!! I'm pretty new to excel macro writing |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This should get you started. I assume data to be copied is in column A, starting row 1. If not, change "A" to appropriate column and change in 1 in "for r=1 .." to correct value. In addition, I assumed column B (to be cleared) was on first worksheet. HTH Sub Copy4() Dim ws1 As Worksheet Dim ws2 As Worksheet Dim lastrow As Long Dim r As Long, rr As Long Set ws1 = Worksheets("Sheet1") Set ws2 = Worksheets("Sheet2") rr = 4 With ws1 lastrow = .Cells(Rows.Count, "A").End(xlUp).Row For r = 1 To lastrow ws2.Cells(rr, "D") = Left(.Cells(r, "A"), 4) rr = rr + 1 Next r ' Clear column B starting at B4 .... .Range("b4:b" & .Cells(Rows.Count, "B").End(xlUp).Row).ClearContents End With End Sub " wrote: I have worksheet 1 that has some data in a column. I want to copy this data in to another worksheet 2 that starts on column 4, row 5, but only the first 4 characters of the data should be put in this cell....and then I want to have it run in a loop so that it copies the entire column from worksheet 1 to worksheet 2 in that same fashion (same column, but increments the row)....How do I do that? Also, how do I clear out a range of data that starts at B4 and then goes down the column? Any help would be appreciated!!! I'm pretty new to excel macro writing |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That worked great!!! Except for do you have an example of the clear
contents in its own loop? Otherwise that is awesome! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro: Copy data to another sheet | Excel Discussion (Misc queries) | |||
1 Create a macro to Copy & paste certain data to another sheet | Excel Discussion (Misc queries) | |||
Macro to copy data from One sheet to another | Excel Discussion (Misc queries) | |||
Macro: Insert, copy and past data from sheet | Excel Discussion (Misc queries) | |||
excel macro to copy data to second sheet | Excel Programming |