A Simple(?) Macro Question

D

DaveJones39

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 |
+-------------------------------------------------------------------+
 
T

Tom Ogilvy

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" <[email protected]>
wrote in message
news:D[email protected]...
 
D

DaveJones39

It says this is a reply to the thread. I'm a little put off by the new
title.

I had a 'simple(?)' macro question. Tom O. responded & I don't see his
e-mail addy, to allow me a private 'Thank you.' So, I'll post it here.


Thanks, Tom. (Geez. This stuff doesn't look simple at all. I've got
some work to do!)
 
T

Tom Ogilvy

probably 95% of the responses that you see in the Excel forum are coming
from the UseNet news group and not from members of the Excel Forum. Those
people responding probably have no knowledge of the Excel forum or what you
are seeing in the Excel forum.

news://msnews.microsoft.com/microsoft.public.excel.programming

--
Regards,
Tom Ogilvy



"DaveJones39" <[email protected]>
wrote in message
news:D[email protected]...
 
D

DaveJones39

This is a new neighborhood (world) for me.

Tom O. mentioned "probably 95% of the responses that you see in the
Excel forum are coming from the UseNet news group and not from members
of the Excel Forum." That's a mystery to me. Are Excel Forum
questions posted in some broader, public forum (UseNet)? Or is this a
HELP function sponsored by MS? I see same individuals responding to
several different Excel Forum queries. Are these folks simply Good
Samaritans, or are they sponsored or paid to do this good work?

(Assuming that Tom O. is a human & not a computer-generated responder,
I'd appreciate a private e-mail so that I could make (brief) contact.)
 
T

Tom Ogilvy

Most of the respondents are using Usenet.

I don't believe anyone in the excel forum is paid to provide answers. (A
microsoft employee only occasionally posts in this usenet group - although
the primary server is provided by microsoft).

my email address is (e-mail address removed)

It is in all my posts in Usenet. Perhaps it is stripped in the excel
forum.

--
Regards,
Tom Ogilvy



"DaveJones39" <[email protected]>
wrote in message
news:D[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top