Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Activecell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Activecell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Activecell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Activecell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Activecell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Activecell value

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
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 to use ActiveCell to mean a particular cell? Jo[_2_] Excel Worksheet Functions 3 October 4th 07 09:38 PM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
activecell.formular1c1 monika Excel Programming 0 April 29th 04 10:13 AM
activecell offset rvik Excel Programming 1 December 24th 03 07:47 AM
how to set activecell? ljb[_2_] Excel Programming 2 November 18th 03 04:49 PM


All times are GMT +1. The time now is 02:22 PM.

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"