Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Simple Macro help

Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and 4)
Columns 1 and 2 are non number values and 3 and 4 are columns with number
values.

At every change in Column 2 i want it to put the value next to it in column
1 and the sum of the values in columns 3 and 4 that correlate with the value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Simple Macro help


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim sh As Worksheet
Dim NextRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Set sh = Worksheets("Sheet1")
If sh.Range("A1").Value = "" Then

NextRow = 1
ElseIf sh.Range("A2").Value = "" Then

NextRow = 2
Else

NextRow = sh.Range("a1").End(xlDown).Row + 1
End If

.Offset(0, -1).Copy sh.Cells(NextRow, "A")
sh.Cells(NextRow, "B").Value = .Offset(0, 1).Value + .Offset(0,
2).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ewing25" wrote in message
...
Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and 4)
Columns 1 and 2 are non number values and 3 and 4 are columns with number
values.

At every change in Column 2 i want it to put the value next to it in
column
1 and the sum of the values in columns 3 and 4 that correlate with the
value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Simple Macro help

It keeps telling me to create a name and when i do it starts a new sub. in a
module.

Not sure what to do.

"Bob Phillips" wrote:


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim sh As Worksheet
Dim NextRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Set sh = Worksheets("Sheet1")
If sh.Range("A1").Value = "" Then

NextRow = 1
ElseIf sh.Range("A2").Value = "" Then

NextRow = 2
Else

NextRow = sh.Range("a1").End(xlDown).Row + 1
End If

.Offset(0, -1).Copy sh.Cells(NextRow, "A")
sh.Cells(NextRow, "B").Value = .Offset(0, 1).Value + .Offset(0,
2).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ewing25" wrote in message
...
Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and 4)
Columns 1 and 2 are non number values and 3 and 4 are columns with number
values.

At every change in Column 2 i want it to put the value next to it in
column
1 and the sum of the values in columns 3 and 4 that correlate with the
value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Simple Macro help

I have no idea what is going on, it didn't here.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ewing25" wrote in message
...
It keeps telling me to create a name and when i do it starts a new sub. in
a
module.

Not sure what to do.

"Bob Phillips" wrote:


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim sh As Worksheet
Dim NextRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Set sh = Worksheets("Sheet1")
If sh.Range("A1").Value = "" Then

NextRow = 1
ElseIf sh.Range("A2").Value = "" Then

NextRow = 2
Else

NextRow = sh.Range("a1").End(xlDown).Row + 1
End If

.Offset(0, -1).Copy sh.Cells(NextRow, "A")
sh.Cells(NextRow, "B").Value = .Offset(0, 1).Value +
.Offset(0,
2).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Ewing25" wrote in message
...
Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other
named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and 4)
Columns 1 and 2 are non number values and 3 and 4 are columns with
number
values.

At every change in Column 2 i want it to put the value next to it in
column
1 and the sum of the values in columns 3 and 4 that correlate with the
value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Simple Macro help

Does it have anything to do with the heading? the Sub name. I have no idea
why its doing this.

"Bob Phillips" wrote:

I have no idea what is going on, it didn't here.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ewing25" wrote in message
...
It keeps telling me to create a name and when i do it starts a new sub. in
a
module.

Not sure what to do.

"Bob Phillips" wrote:


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim sh As Worksheet
Dim NextRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Set sh = Worksheets("Sheet1")
If sh.Range("A1").Value = "" Then

NextRow = 1
ElseIf sh.Range("A2").Value = "" Then

NextRow = 2
Else

NextRow = sh.Range("a1").End(xlDown).Row + 1
End If

.Offset(0, -1).Copy sh.Cells(NextRow, "A")
sh.Cells(NextRow, "B").Value = .Offset(0, 1).Value +
.Offset(0,
2).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Ewing25" wrote in message
...
Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other
named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and 4)
Columns 1 and 2 are non number values and 3 and 4 are columns with
number
values.

At every change in Column 2 i want it to put the value next to it in
column
1 and the sum of the values in columns 3 and 4 that correlate with the
value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Simple Macro help

What heading?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ewing25" wrote in message
...
Does it have anything to do with the heading? the Sub name. I have no idea
why its doing this.

"Bob Phillips" wrote:

I have no idea what is going on, it didn't here.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Ewing25" wrote in message
...
It keeps telling me to create a name and when i do it starts a new sub.
in
a
module.

Not sure what to do.

"Bob Phillips" wrote:


Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B:B" '<== change to suit
Dim sh As Worksheet
Dim NextRow As Long

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Set sh = Worksheets("Sheet1")
If sh.Range("A1").Value = "" Then

NextRow = 1
ElseIf sh.Range("A2").Value = "" Then

NextRow = 2
Else

NextRow = sh.Range("a1").End(xlDown).Row + 1
End If

.Offset(0, -1).Copy sh.Cells(NextRow, "A")
sh.Cells(NextRow, "B").Value = .Offset(0, 1).Value +
.Offset(0,
2).Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Ewing25" wrote in message
...
Heres what i want the macro to do.

I have a spreadsheet with 2 tabs. one named commisions and the other
named
summary.

In the commisions tab there are 4 columns (Lets call them 1,2,3, and
4)
Columns 1 and 2 are non number values and 3 and 4 are columns with
number
values.

At every change in Column 2 i want it to put the value next to it in
column
1 and the sum of the values in columns 3 and 4 that correlate with
the
value
in Column2.

And i want it to display the information in the Summary Tab.

If anyone can help that would be amazing.

Thanks!
Alex









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
Simple Macro help? The Message Excel Discussion (Misc queries) 2 December 14th 09 05:14 PM
Help with simple macro Sam Commar Excel Discussion (Misc queries) 3 April 15th 08 04:30 PM
Simple Macro? [email protected][_2_] Excel Programming 1 August 2nd 06 08:48 PM
Simple Macro - I Think? vinclanz[_2_] Excel Programming 1 September 27th 04 01:21 AM
Simple Macro - I Think? vinclanz Excel Programming 1 September 22nd 04 01:32 AM


All times are GMT +1. The time now is 10:00 PM.

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"