#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default need a VB code

hi, i have the code below which takes the value in cell U17 everytime it
changes, and places it in column A on a sheet called graphs thereby forming a
list down the sheet of all the values that appear in cell U17, for charting
purposes.

What i would like to do is to be able to duplicate this for different cells.
i would like to have the cell values of W25 appear in a list in column K on
the 'graphs' sheet. Could you please give me some code that will enable me to
capture the values for these two cells in sheet1 into the sheet called graphs?

any help would be greatly appreciated, thank you.

Private Sub Worksheet_Calculate()
Dim Dest As Range
With Sheets("graphs")
Set Dest = .Range("A" & Rows.Count).End(xlUp)
If Range("U17") < Dest Then _
Dest.Offset(1) = Range("U17")
End With
End Sub

--
thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default need a VB code

Hi

This changed code should do it:

Private Sub Worksheet_Calculate()
Dim DestU As Range
Dim DestW As Range
With Sheets("graphs")
Set DestU = .Range("A" & Rows.Count).End(xlUp)
Set DestW = .Range("K" & Rows.Count).End(xlUp)
If Range("U17") < DestU Then _
DestU.Offset(1) = Range("U17")
If Range("W25") < DestW Then _
DestW.Offset(1) = Range("W25")
End With
End Sub

Regards,
Per

"Morgan" skrev i meddelelsen
...
hi, i have the code below which takes the value in cell U17 everytime it
changes, and places it in column A on a sheet called graphs thereby
forming a
list down the sheet of all the values that appear in cell U17, for
charting
purposes.

What i would like to do is to be able to duplicate this for different
cells.
i would like to have the cell values of W25 appear in a list in column K
on
the 'graphs' sheet. Could you please give me some code that will enable me
to
capture the values for these two cells in sheet1 into the sheet called
graphs?

any help would be greatly appreciated, thank you.

Private Sub Worksheet_Calculate()
Dim Dest As Range
With Sheets("graphs")
Set Dest = .Range("A" & Rows.Count).End(xlUp)
If Range("U17") < Dest Then _
Dest.Offset(1) = Range("U17")
End With
End Sub

--
thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default need a VB code

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim strColumn As String, lngRow As Long, ws As Worksheet

If Target.Count < 1 Or Target.Text = "" Then Exit Sub

If Target.Address = "$U$17" Then
strColumn = "A"
ElseIf Target.Address = "$W$25" Then
strColumn = "K"
End If

If strColumn < vbNullString Then
Set ws = Worksheets("graphs")
If WorksheetFunction.CountIf(ws.Range(strColumn & _
"1").EntireColumn, Target.Text) = 0 Then
Application.EnableEvents = False
lngRow = ws.Cells(Rows.Count, strColumn).End(xlUp).Row
ws.Range(strColumn & lngRow + 1) = Target.Text
Application.EnableEvents = True
End If
End If

End Sub


--
Jacob


"Morgan" wrote:

hi, i have the code below which takes the value in cell U17 everytime it
changes, and places it in column A on a sheet called graphs thereby forming a
list down the sheet of all the values that appear in cell U17, for charting
purposes.

What i would like to do is to be able to duplicate this for different cells.
i would like to have the cell values of W25 appear in a list in column K on
the 'graphs' sheet. Could you please give me some code that will enable me to
capture the values for these two cells in sheet1 into the sheet called graphs?

any help would be greatly appreciated, thank you.

Private Sub Worksheet_Calculate()
Dim Dest As Range
With Sheets("graphs")
Set Dest = .Range("A" & Rows.Count).End(xlUp)
If Range("U17") < Dest Then _
Dest.Offset(1) = Range("U17")
End With
End Sub

--
thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default need a VB code

Forgot to mention that the code posted will not track non-subsequent
duplicate entires made in those cells...If that is not your
requirment...replace the code as below

If strColumn < vbNullString Then
Set ws = Worksheets("graphs")
Application.EnableEvents = False
lngRow = ws.Cells(Rows.Count, strColumn).End(xlUp).Row
ws.Range(strColumn & lngRow + 1) = Target.Text
Application.EnableEvents = True
End If



--
Jacob


"Jacob Skaria" wrote:

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim strColumn As String, lngRow As Long, ws As Worksheet

If Target.Count < 1 Or Target.Text = "" Then Exit Sub

If Target.Address = "$U$17" Then
strColumn = "A"
ElseIf Target.Address = "$W$25" Then
strColumn = "K"
End If

If strColumn < vbNullString Then
Set ws = Worksheets("graphs")
If WorksheetFunction.CountIf(ws.Range(strColumn & _
"1").EntireColumn, Target.Text) = 0 Then
Application.EnableEvents = False
lngRow = ws.Cells(Rows.Count, strColumn).End(xlUp).Row
ws.Range(strColumn & lngRow + 1) = Target.Text
Application.EnableEvents = True
End If
End If

End Sub


--
Jacob


"Morgan" wrote:

hi, i have the code below which takes the value in cell U17 everytime it
changes, and places it in column A on a sheet called graphs thereby forming a
list down the sheet of all the values that appear in cell U17, for charting
purposes.

What i would like to do is to be able to duplicate this for different cells.
i would like to have the cell values of W25 appear in a list in column K on
the 'graphs' sheet. Could you please give me some code that will enable me to
capture the values for these two cells in sheet1 into the sheet called graphs?

any help would be greatly appreciated, thank you.

Private Sub Worksheet_Calculate()
Dim Dest As Range
With Sheets("graphs")
Set Dest = .Range("A" & Rows.Count).End(xlUp)
If Range("U17") < Dest Then _
Dest.Offset(1) = Range("U17")
End With
End Sub

--
thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default need a VB code

thank you both very much, very helpful!

"Per Jessen" wrote:

Hi

This changed code should do it:

Private Sub Worksheet_Calculate()
Dim DestU As Range
Dim DestW As Range
With Sheets("graphs")
Set DestU = .Range("A" & Rows.Count).End(xlUp)
Set DestW = .Range("K" & Rows.Count).End(xlUp)
If Range("U17") < DestU Then _
DestU.Offset(1) = Range("U17")
If Range("W25") < DestW Then _
DestW.Offset(1) = Range("W25")
End With
End Sub

Regards,
Per

"Morgan" skrev i meddelelsen
...
hi, i have the code below which takes the value in cell U17 everytime it
changes, and places it in column A on a sheet called graphs thereby
forming a
list down the sheet of all the values that appear in cell U17, for
charting
purposes.

What i would like to do is to be able to duplicate this for different
cells.
i would like to have the cell values of W25 appear in a list in column K
on
the 'graphs' sheet. Could you please give me some code that will enable me
to
capture the values for these two cells in sheet1 into the sheet called
graphs?

any help would be greatly appreciated, thank you.

Private Sub Worksheet_Calculate()
Dim Dest As Range
With Sheets("graphs")
Set Dest = .Range("A" & Rows.Count).End(xlUp)
If Range("U17") < Dest Then _
Dest.Offset(1) = Range("U17")
End With
End Sub

--
thanks


.

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 07:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 08:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 04:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 10:54 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 05:00 PM


All times are GMT +1. The time now is 09:58 AM.

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"