-
Apr 26th, 2011, 03:27 AM
#1
Thread Starter
New Member
-
Apr 26th, 2011, 03:42 AM
#2
Re: Simple macro, yet trouble
This is the VB.NET forum, for questions on VB.NET. VBA questions belong in the VBA forum. I have asked the mods to move this thread.
-
Apr 26th, 2011, 06:41 AM
#3
Re: Simple macro, yet trouble
Moved. Thanks for the report jmcilhinney
Gary
-
Apr 26th, 2011, 06:43 AM
#4
Re: Simple macro, yet trouble
We must have both moved this at the same time.
I have an additional question. You mention Sheet1 so it is presumed that you are using Excel VBA.
It is important for anyone wishing to assist you to know what version of Excel you are using.
-
Apr 26th, 2011, 07:08 AM
#5
Re: Simple macro, yet trouble
Another thing to note is what do you consider the first empty cell? Do you start in the first column and keep going down? Or start in the first row and keep going across? Or a more difficult square pattern? Rectangle? So you see, the first cell can be many different things to many different people and I presume only one way will work for you.
The first step is to CLEARLY and COMPLETELY define the problem AND solution.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Apr 26th, 2011, 07:48 AM
#6
Re: Simple macro, yet trouble
try
vb Code:
range("a65535").end(xlup).offset(1) = range("b1")
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 27th, 2011, 08:09 AM
#7
Junior Member
Re: Simple macro, yet trouble
I think westconn way works best, but if you need a number instead of a address this works as well:
vb Code:
for i = 1 to 256 ' ' 256 is the maximum number of cols excel contains. If isEmpty(Cells(0,i)) then Exit For ' ' No endless loops for me, right next i Cells(0,i).paste ' ' This is for pasting, not sure if this works like this...
That will give you the column number. Swap the "0" and the "i" in the "isEmpty" statement to get the row number. Make sure you change the 256 to 65536 when doing rows.
Last edited by unleash; Apr 27th, 2011 at 04:48 PM.
Reason: Did it the wrong way round... thanks westconn1.
"For all men are equal before fish."
~ Herbert Hoover ~
-
Apr 27th, 2011, 04:41 PM
#8
Re: Simple macro, yet trouble
Swap the "0" and the "i" in the "isEmpty" statement to get the column number.
other way round, the example is doing columns
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 27th, 2011, 04:47 PM
#9
Junior Member
Re: Simple macro, yet trouble
Sorry, my bad.
I changed the original post, so nobody gets confused
"For all men are equal before fish."
~ Herbert Hoover ~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|