Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Z = ActiveCell.Value
-- Rob van Gelder - http://www.vangelder.co.nz/excel "Shamsul Islam" wrote in message ... Hi I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rob ,
Although it is not necessary, and looks odd, the OP's syntax is not wrong. What might be wrong is that the activecell might be a string or something, not an integer. Shamsul, also you don't need to initialise variables before setting i9t to a value. Try this Dim Z As Integer With ActiveCell.Range("A1") If IsNumeric(.Value) Then Z = .Value End If End With -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rob van Gelder" wrote in message ... Z = ActiveCell.Value -- Rob van Gelder - http://www.vangelder.co.nz/excel "Shamsul Islam" wrote in message ... Hi I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My assumption was that the cell content was an integer - I guess I should
have detailed that assumption. If the cell content type cannot be guaranteed, I would recommend setting variable to type of Variant. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Bob Phillips" wrote in message ... Rob , Although it is not necessary, and looks odd, the OP's syntax is not wrong. What might be wrong is that the activecell might be a string or something, not an integer. Shamsul, also you don't need to initialise variables before setting i9t to a value. Try this Dim Z As Integer With ActiveCell.Range("A1") If IsNumeric(.Value) Then Z = .Value End If End With -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rob van Gelder" wrote in message ... Z = ActiveCell.Value -- Rob van Gelder - http://www.vangelder.co.nz/excel "Shamsul Islam" wrote in message ... Hi I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Thanks for your reply, but it still does not work. Here is the full macro: Sub XXXX() Dim X As Integer Dim Y As Integer Dim Z As Integer Dim ZY As Integer Let X = Range("A1").Value Y = -15 ZY = 0 For Counts = 1 To X Y = Y - 5 Z = 0 Application.Goto Reference:="ProjTotal04" ActiveCell.Offset(0, Y).Select Z = ActiveCell.Value ZY = ZY + Z Application.Goto Reference:="ProjTotal04" ActiveCell.Value = ZY Next End Sub Macro alwway stops at Z = ActiveCell.Value Please help. Thanks Sham -----Original Message----- Z = ActiveCell.Value -- Rob van Gelder - http://www.vangelder.co.nz/excel "Shamsul Islam" wrote in message ... Hi I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it definitely an integer in that cell? What error message are you
getting? Jeff "Shamsul Islam" wrote in message ... Hi Thanks for your reply, but it still does not work. Here is the full macro: Sub XXXX() Dim X As Integer Dim Y As Integer Dim Z As Integer Dim ZY As Integer Let X = Range("A1").Value Y = -15 ZY = 0 For Counts = 1 To X Y = Y - 5 Z = 0 Application.Goto Reference:="ProjTotal04" ActiveCell.Offset(0, Y).Select Z = ActiveCell.Value ZY = ZY + Z Application.Goto Reference:="ProjTotal04" ActiveCell.Value = ZY Next End Sub Macro alwway stops at Z = ActiveCell.Value Please help. Thanks Sham -----Original Message----- Z = ActiveCell.Value -- Rob van Gelder - http://www.vangelder.co.nz/excel "Shamsul Islam" wrote in message ... Hi I want a variable value, to be the value of the activecell. I've tried the following: Dim Z As Integer Z = 0 Z = ActiveCell.Range("A1").Value The code doesn't work. Please advise. Thanks Sham . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to use ActiveCell to mean a particular cell? | Excel Worksheet Functions | |||
If activecell.column = variable then activecell,offset (0,1) | Excel Discussion (Misc queries) | |||
activecell.formular1c1 | Excel Programming | |||
activecell offset | Excel Programming | |||
how to set activecell? | Excel Programming |