View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default A Simple(?) Macro Question

Assume that horizontal numbers start in B1 and the vertical numbers start in
A2

Option Explicit
Sub BuildData()
Dim cnt As Long, i As Long, j As Long
Dim bMatch As Boolean, lastrow As Long
Dim lastCol As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
lastCol = Cells(1, Columns.Count _
).End(xlToLeft).Column
cnt = 1
For j = 2 To lastCol
bMatch = False
For i = 2 To lastrow
If Cells(i, 1).Value = Cells(1, j).Value Then
bMatch = True
End If
If bMatch Then
Cells(i, j).Value = Cells(i, 1).Value _
* Cells(1, j).Value
Cells(cnt, lastCol + 2).Value = _
Cells(i, j).Value
cnt = cnt + 1
End If
Next
Next

End Sub


--
Regards,
Tom Ogilvy



"DaveJones39"
wrote in message
...

I'm a newbie. I just learned of this forum.

I'm struggling with macros in Excel. I want to do a few very simple
operations
a couple million times. I need to mechanize the process.

I can do some simple stuff, like "multiply the numbers in that column
by this
number." But then I'm stuck on how to maneuver to a different position
& do the same operation again. In Lotus, I could use RIGHT, DOWN, END &
stuff like that. I'm not having much luck with Excel (&, I assume,
VBA).

I was surprised that I couldn't attach an Excel spreadsheet to this
message. (Maybe there's a trick to learn.) I've attached it as .pdf.
I hope I've explained what I want to do. The example is trivial. But
doing it a million times without a macro would be a bother.

It would certainly be easiest if someone could return an Excel
spreadsheet. Then I could fool with the code & get to my real problem.


Thanks,

DJQ


+-------------------------------------------------------------------+
|Filename: Excel Question 04-21-06.pdf |
|Download: http://www.excelforum.com/attachment.php?postid=4676 |
+-------------------------------------------------------------------+

--
DaveJones39
------------------------------------------------------------------------
DaveJones39's Profile:

http://www.excelforum.com/member.php...o&userid=33734
View this thread: http://www.excelforum.com/showthread...hreadid=535128