ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign Active Cell Value (https://www.excelbanter.com/excel-programming/285054-assign-active-cell-value.html)

S.S.

Assign Active Cell Value
 
I am trying to assign the active cell a value from another
cell on the work sheet.

The following code does not seem to work:

Do While Count < 60 ' Inner loop.
Count = Count + 1 ' Increment Counter.
If ActiveSheet.Cells(Count, 1) = "" Then
ActiveSheet.Cells(Count, 1).Value = Name
ActiveSheet.Cells(Count, 16).Value = Initials
ActiveSheet.Cells(Count, 2).Activate
ActiveCell = ActiveSheet.Cells("S18").Value
Exit Do ' Exit inner loop.
End If
Loop

The error occurs at:
ActiveCell = ActiveSheet.Cells("S18").Value

I have tried various combinations of this and none seem to
work.

Any suggestions?

Thanks
SS


No Name

Assign Active Cell Value
 
It could be from your outter loop (since S is column 18
and you don't reference it anywhere in this code)

Make sure the original value of count is 0
Is 'Name' a string? If so, you'll need quotes
(goes the same for 'Initials')

HTH

-----Original Message-----
I am trying to assign the active cell a value from

another
cell on the work sheet.

The following code does not seem to work:

Do While Count < 60 ' Inner loop.
Count = Count + 1 ' Increment Counter.
If ActiveSheet.Cells(Count, 1) = "" Then
ActiveSheet.Cells(Count, 1).Value = Name
ActiveSheet.Cells(Count, 16).Value = Initials
ActiveSheet.Cells(Count, 2).Activate
ActiveCell = ActiveSheet.Cells("S18").Value
Exit Do ' Exit inner loop.
End If
Loop

The error occurs at:
ActiveCell = ActiveSheet.Cells("S18").Value

I have tried various combinations of this and none seem

to
work.

Any suggestions?

Thanks
SS

.


Doug Glancy

Assign Active Cell Value
 
SS,

Try substituting Range for Cells in your problem line, i.e.:

ActiveCell = ActiveSheet.Range("S18").Value

Also, I think you'd be better off with a for/next loop than the Do While,
and I'd avoid using VBA reserved words like "Count", so for example:

For Counter = 1 to 60
' your code here
Next

hth,

Doug


"S.S." wrote in message
...
I am trying to assign the active cell a value from another
cell on the work sheet.

The following code does not seem to work:

Do While Count < 60 ' Inner loop.
Count = Count + 1 ' Increment Counter.
If ActiveSheet.Cells(Count, 1) = "" Then
ActiveSheet.Cells(Count, 1).Value = Name
ActiveSheet.Cells(Count, 16).Value = Initials
ActiveSheet.Cells(Count, 2).Activate
ActiveCell = ActiveSheet.Cells("S18").Value
Exit Do ' Exit inner loop.
End If
Loop

The error occurs at:
ActiveCell = ActiveSheet.Cells("S18").Value

I have tried various combinations of this and none seem to
work.

Any suggestions?

Thanks
SS





All times are GMT +1. The time now is 06:03 PM.

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