ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to transfer #'s from one column to the next (https://www.excelbanter.com/excel-programming/377425-how-transfer-s-one-column-next.html)

Tonya

how to transfer #'s from one column to the next
 
I am setting up a spreadsheet (budget purposes) and what I am trying to do is
when you enter the budget number and amount in 2 separate columns, I want the
amount to automatically go under the budget number on the spreadsheet. Any
suggestions? I know excel pretty good, but am not the greatest with
forumulas.
--
TP

Tom Ogilvy

how to transfer #'s from one column to the next
 
right click on the worksheet and put in code like this.

Assume the budget amount will be placed in cell B2 and the budget number in A2

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
If Target.Address = "$B$2" Then
Application.EnableEvents = False

s = Target.Offset(0, -1).Value
Target.Offset(0, -1).ClearContents
Set rng = Cells.Find(What:=s, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
If IsEmpty(rng.Offset(1, 0)) Then
Set rng = rng.Offset(1, 0)
Else
Set rng = rng.End(xlDown)(2)
End If
rng.Value = Target
Target.ClearContents
Else
MsgBox s & " was not found"
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

This is just a guess since I don't know anything about the layout of your
sheet.

--
Regards,
Tom Ogilvy



"Tonya" wrote:

I am setting up a spreadsheet (budget purposes) and what I am trying to do is
when you enter the budget number and amount in 2 separate columns, I want the
amount to automatically go under the budget number on the spreadsheet. Any
suggestions? I know excel pretty good, but am not the greatest with
forumulas.
--
TP



All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com