PDA

View Full Version : Sleeper: Real N00B help about free cells



IVY440
03-31-2005, 06:32 AM
Hello everybody, I'm pretty new with the VBA things and I'm trying o do something special. I'll try to explain.

I'm doing a calculation and when a button is pressed I want to save that number in Sheet2. But the previous savings also have to be saved.
So I have done a calculation, I press a button to save it in A1 on Sheet 2.
I'm doing a new calculation and I press again the button to save it. But I don't want the number in A1 to be lost, so I want that the macro automatically searchs for the next free cell.
How can I do this? :dunno
Do I also have to include the fact that only the number and not the formula has to be saved?

Thanks
IVY440 :beerchug:

sandam
03-31-2005, 06:50 AM
would you like to move across, column to column or down, row by row?

IVY440
03-31-2005, 06:53 AM
Sorry I don't get or don't you want to help me? :dunno :(

sandam
03-31-2005, 07:21 AM
My apologies for not saying it earlier - Welcome to VBAX

And yes I would like to help you, I just need some more information about your problem. I would like to know If you want to place the "new" answer when you redo your calculation into the column next to old one (same row different cell Eg 1st answer in A1, next answer in B1) or into the row below (same column, different row Eg 1st Answer A1, next answer A2 etc) on sheet two? Because there are two ways of looking for the next empty cell, either by column or by row.



Dim LastColumn As Integer
LastColumn = Range("A1").Column.End(xlRight)
Range("A"&(LastColumn+1)).Value = NewAnswer

Or

Dim
LastRow As Integer
LastRow = Range("A65536").Row.End(xlUp)
Range("A"&(LastRow+1)).Value = NewAnswer

IVY440
03-31-2005, 07:47 AM
Sorry sandam, my mistake, I didn't see the post, only the very big signature.
Sorry for that :banghead:
It has to be the next row. I'll try to check if it's possible in your way (not that I doubt about the real VBA'ers :thumb

Euhm, when I compile it, it gives an error on this line

LastRow = Range("A65536").Row.End(xlUp)

with the notification for .Row: Invalid Qualifier

What to do? :dunno

sandam
03-31-2005, 07:58 AM
My mistake :doh:

the line should be -


LastRow = Range("A65536").End(xlUp).Row

IVY440
03-31-2005, 09:34 AM
How can I make the NewAnswer a special paste?
Can I just put:

Range("A"&(LastRow+1)).Value = PasteSpecial(Value)

Or how do I have to encode it?

IVY440
04-01-2005, 09:14 AM
I still have problems with this thread.
When I run the macro, he puts the value in Sheet1 and I want it in Sheet2.
Also he doesn't take the first free cell in Sheet2.

Please help :dunno

This doesn't work
He gives the error that the merged cells has to have the same size. Error on line 6


Dim LastRow As Integer
Range("B15").Select
Selection.Copy
ActiveSheet.Next.Select
LastRow = Range("A65536").End(xlUp).Row
Range("A" & (LastRow + 1)).PasteSpecial (xlPasteValues)
Sheets("Sheet1").Select