Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Autocopy from one cell to another cell in a spreadsheet

I need help creating a macro to copy from a cell in sheet1 to a cell in
sheet2. Though when it pastes I can't have it fill the same cell over
again I need it to paste it in the next cell down from it.


Example:


Sheet1 - Sheet2


B12 - B2 and after the person clicks the macro the next would move
down to B3, B4, B5...
D12 - C2, C3, C4... so on and so forth
I5 - A2
I17 - E2
G12 - D2
I22 - F2
I27 - G2

I just can't seem to figure this out because I have almost 0 knowledge
of VB. Can someone help me with a step by step?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Autocopy from one cell to another cell in a spreadsheet

One way:

Option Explicit
'B12 - B2
'D12 - C2
'I5 - A2
'I17 - E2
'G12 - D2
'I22 - F2
'I27 - G2
Sub testme()

Dim fWks As Worksheet
Dim tWks As Worksheet

Dim fAddr As Variant
Dim tCol As Variant

Dim cCtr As Long
Dim oRow As Long

fAddr = Array("b12", "d12", "i5", "i17", "g12", "i22", "i27")
tCol = Array("b", "c", "a", "e", "d", "f", "g")

If UBound(fAddr) < UBound(tCol) Then
MsgBox "design error--not same number of columns/cells)"
End If

Set fWks = Worksheets("sheet1")
Set tWks = Worksheets("Sheet2")

With tWks
oRow = .Cells(.Rows.Count, tCol(LBound(tCol))).End(xlUp).Row + 1
End With

With fWks
If IsEmpty(.Range(fAddr(LBound(fAddr)))) Then
MsgBox "Please enter data in: " & fAddr(LBound(fAddr))
Exit Sub
End If

For cCtr = LBound(fAddr) To UBound(fAddr)
tWks.Cells(oRow, tCol(cCtr)).Value = .Range(fAddr(cCtr)).Value
.Range(fAddr(cCtr)).ClearContents '???
Next cCtr
End With

End Sub

wrote:

I need help creating a macro to copy from a cell in sheet1 to a cell in
sheet2. Though when it pastes I can't have it fill the same cell over
again I need it to paste it in the next cell down from it.

Example:

Sheet1 - Sheet2

B12 - B2 and after the person clicks the macro the next would move
down to B3, B4, B5...
D12 - C2, C3, C4... so on and so forth
I5 - A2
I17 - E2
G12 - D2
I22 - F2
I27 - G2

I just can't seem to figure this out because I have almost 0 knowledge
of VB. Can someone help me with a step by step?


--

Dave Peterson
Reply
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
How can I autocopy text from one textbox to another using VBA in E SunFUd01 Excel Discussion (Misc queries) 0 November 18th 09 06:24 PM
how do i make a cell a search cell for a spreadsheet adam Excel Worksheet Functions 5 November 3rd 09 11:16 AM
Autocopy formula without VB johnsonlnl29 Excel Discussion (Misc queries) 1 December 15th 06 04:28 PM
Autocopy formula to cells ASU Excel Discussion (Misc queries) 1 September 8th 06 04:43 PM
Autocopy formula to cells Marie Bayes Excel Discussion (Misc queries) 4 August 1st 06 04:32 PM


All times are GMT +1. The time now is 04:11 AM.

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

About Us

"It's about Microsoft Excel"