JustAnswer > Programming
Ask A Question|Register|Login|Help
JustAnswer

Programming

Ask a Programming Question, Get an Answer ASAP!

Have your own Programming question?

3 Programmers are Online Now
characters left:
Not a Programming Question?
Bookmark and Share

Question

I am trying to either write a macro to autofill upwards, ie I have 4500 rows of info and i have different text on various rows and I would like to fill in the blanks above them. Any ideas - I can fill down easily - but I am having probs filling upwards.....

Submitted: 309 days and 9 hours ago.
Category: Programming
Value: $15
Status: AWAITING CUSTOMER ACTION
+
Read More

Optional Information

OS: Windows XP; Browser: AOL

Already Tried:
excel/goto/special/blanks/....
I don't want to have to range my macros b/c it's something that will change weekly.....

Posted by John D 309 days and 9 hours ago.

Answer

Hi,

 

Let's assume that you want to fill up from cell A4500 to cell A1, here is the macro to do it.

 

Sub Fillup()

Range(Cells(4500, 1), Cells(1, 1)).FillUp

End Sub

 

Hope this helps. If you have any questions please feel free to ask.

309 days and 9 hours ago.

Reply

this unfortunately doesn't work b/c every 10 rows (it varies) there's different text - I want it to fill the spaces in between with the text below. Hence the fill up - this filled everything up with what was at the bottom.

 

 

Posted by John D 309 days and 9 hours ago.

Answer

You said the Fill Down worked but you couldn't do it with the Fill Up, so it was assumed that whatever your were doing with the Fill Down can be similarly done with the Fill Up.

 

Anyway, so you want to fill only the blank rows in the range? If so can you tell me exactly the range (first cell and last cell including column numbers) and which cell has the data to be copied to the empty cells.

 

Thanks.

 

309 days and 9 hours ago.

Reply

P7:p4686 and the rows that have info on them varies 15/23/31/39/54/56/66/74/82/90/etc...

Posted by John D 309 days and 9 hours ago.

Answer

I don't need to know the specific rows that have values, only the concept. Are you trying to fill up the empty cells using the data from the first non empty cell that comes after each block of empty rows?

 

One other thing, since you are able to do it with Fill Down, the logical and simplest way to do this is if you can post the method or code that you are using for the Fill Down and I will modify it for you to Fill Up.

 

309 days and 8 hours ago.

Reply

I can do the fill down with excel/goto/special/blanks/....

but that won't work upwards

or

Sub CopyDown()
Const StartRowNo = 1
Const EndRowNo = 2000
Const ColumnNo = 2
Dim curText As String, curRowNo As Long

curRowNo = StartRowNo
Do While IsEmpty(Cells(curRowNo, ColumnNo)) And curRowNo <= EndRowNo
curRowNo = curRowNo + 1
Loop

Do While curRowNo <= EndRowNo
If IsEmpty(Cells(curRowNo, ColumnNo).Value) Then
Cells(curRowNo, ColumnNo).Value = curText
Else
curText = Cells(curRowNo, ColumnNo).Value
End If
curRowNo = curRowNo + 1
Loop
End Sub

 

 

Posted by John D 309 days and 8 hours ago.

Answer

I see.

 

Ok here is a much simpler way to fill up the blank cells (using the value of the cell that follows the blanks).

 

FILE

 

Check it and let me know if it needs any modification.

 

309 days and 8 hours ago.

Reply

it looks as though this should have been only column "p" was affected however, every column did the fillup?

Posted by John D 309 days and 7 hours ago.

Answer

Yes, that is because you specified column P when you gave me the range "P7:p4686".

 

Now which columns do you want to include in the fill up operation?

 

 

309 days and 7 hours ago.

Reply

I only want column p, but it's doing the whole sheet!

Accepted Answer

Ok, I see where the problem is. My bad

 

Please change the 1 in this line :

Range(Cells(i, "P"), Cells(i - k, 1)).Select

 

to "P" , so it will become like this:

Range(Cells(i, "P"), Cells(i - k, "P")).Select

 

Let me know.

Picture
Expert: John D
Pos. Feedback: 99.7 %
Accepts: 
Answered: 1/15/2009

BS Degree in Engineering

20 years experience in Excel programming and various major applications.

309 days and 7 hours ago.

Reply

Still doesn't work - it keeps flipping back and forth btwn the bttm cell with info and the next one with info

309 days and 7 hours ago.

Reply

I got it....

Posted by John D 309 days and 7 hours ago.

Answer

You need to replace the word "Select" in that line by "FillUp". You see the Select is used only for testing to see where the fillup will be applied.

 

 

+
Read More

Related Programming Questions

  • i am a farily new designer using cs4/as3. i currently have
  • how do I use the same database for my OsCommerce installatio...
  • Write a C++ function to generate an N-node random binary sea...
  • I have 2 more programs and 25 multiple choice questions I ne...
  • I have been using Mozilla Thunderbird happily for some time
  • I've built a timesheet template for my staff. I've formatted
  • I have building a website with user authentication. I have
  • Hi! I wrote a VB6 enterprise program with SQL SERVER 7. I



Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Question List | Become an Expert | Terms of Service | Security & Privacy | About Us
© 2003-2009 JustAnswer Corp.