Computing.Net > Forums > Programming > Excel macro

Excel macro

Reply to Message Icon

Original Message
Name: AlwaysWillingToLearn
Date: March 14, 2007 at 05:35:05 Pacific
Subject: Excel macro
OS: winxp pro
CPU/Ram: p4
Model/Manufacturer: msi
Comment:

in excel i wanted to be able to find the last cell in column a that is being is being used. so for example if the last cell is A10 then i would set a variable to get this number.

ive done this using some code.

but what i want to do is

for i - 0 to LastCell

each cell . value = "Hello"

next i

how do i do this, thing is i know you can say

Dim BCell as Range

For each BCell in range("A1:A10")
BCell.value = "Hello"
next BCell

But i do not know what the "A10" will actually be as people might add / remove rows which means the last cell will change,

so basically

Dim BCell as Range

For each BCell in range("A1:LastCell")
BCell.value = "Hello"
next BCell

this didnt work tho,

any help please??

Thanks,


Report Offensive Message For Removal


Response Number 1
Name: AlwaysWillingToLearn
Date: March 14, 2007 at 06:56:30 Pacific
Reply: (edit)

ahh figured it out

For each BCell in range("A1", LastCell)
BCell.value = "Hello"
next BCell

used a comma to seperate the cells

cheers anyways guys


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Excel macro

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge