ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A Simple(?) Macro Question (https://www.excelbanter.com/excel-programming/359500-simple-macro-question.html)

DaveJones39

A Simple(?) Macro Question
 

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


Tom Ogilvy

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




DaveJones39[_2_]

A Simple(?) Macro Question
 

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!)


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


Tom Ogilvy

A Simple(?) Macro Question
 
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/microsof...el.programming

--
Regards,
Tom Ogilvy



"DaveJones39"
wrote in message
...

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!)


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

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




DaveJones39[_3_]

A Simple(?) Macro Question
 

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.)


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


Tom Ogilvy

A Simple(?) Macro Question
 
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

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

--
Regards,
Tom Ogilvy



"DaveJones39"
wrote in message
...

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.)


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

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





All times are GMT +1. The time now is 10:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com