PC Review


Reply
Thread Tools Rate Thread

Excel table macro

 
 
Shiraz Mistry
Guest
Posts: n/a
 
      30th Jun 2003
Hi all,

I want to position my cursor in a cell (in Column A) and press a macro
button to fill in the rest of the week.

For example, cell A91 should fill the rest of the week as the above week,
that is, A81:H89.

Currently, this is the code for the table-

Sub Table()
'
' Table Macro
' Macro recorded 6/24/03 by Shiraz Mistry
'
'
Range("A71:H79").Select
Selection.Copy
Range("A81").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
I know it has something to do with the above range:

Range("A81").Select

but I am not sure what and how to change this line.

I can send the workbook to people that may be interested.

Any help would be appreciated,

Thanks,

Shiraz J. Mistry



 
Reply With Quote
 
 
 
 
J.E. McGimpsey
Guest
Posts: n/a
 
      30th Jun 2003
One way:

Public Sub Table()
With ActiveCell
If .Row > 10 Then _
.Offset(-10, 0).Resize(10, 8).Copy Destination:= _
.Cells
End With
End Sub

This uses the active cell, and, as long as it's in Row 11 or higher,
copies the 10 rows above it (and 8 columns wide) to the activecell.

The "." are shorthand for the object that follows the "With" (i.e.,
ActiveCell).

Notice that it avoids making any Selections - using the Range
objects directly (in this case ActiveCell and the ranges derived
from it) makes your code smaller, faster, and IMO easier to maintain.


BTW - most regulars read .misc, .worksheet.functions and
..programming, so, while cross-posting isn't nearly as bad as posting
individual messages to different groups, it's largely not necessary.



In article <3effdfa3$0$26637$(E-Mail Removed)>,
"Shiraz Mistry" <(E-Mail Removed)> wrote:

> Hi all,
>
> I want to position my cursor in a cell (in Column A) and press a macro
> button to fill in the rest of the week.
>
> For example, cell A91 should fill the rest of the week as the above week,
> that is, A81:H89.
>
> Currently, this is the code for the table-
>
> Sub Table()
> '
> ' Table Macro
> ' Macro recorded 6/24/03 by Shiraz Mistry
> '
> '
> Range("A71:H79").Select
> Selection.Copy
> Range("A81").Select
> ActiveSheet.Paste
> Application.CutCopyMode = False
> End Sub
> I know it has something to do with the above range:
>
> Range("A81").Select
>
> but I am not sure what and how to change this line.
>
> I can send the workbook to people that may be interested.
>
> Any help would be appreciated,
>
> Thanks,
>
> Shiraz J. Mistry
>
>
>

 
Reply With Quote
 
Shiraz Mistry
Guest
Posts: n/a
 
      30th Jun 2003
Thank you. Again, I am totally in awe of your quick answer. It does work and
I am understanding the code with your explanations.

Also thanks for the kind reminder of cross posting. I will remember this in
the future.

Shiraz J. Mistry

"J.E. McGimpsey" <(E-Mail Removed)> wrote in message
news:jemcgimpsey-(E-Mail Removed)...
> One way:
>
> Public Sub Table()
> With ActiveCell
> If .Row > 10 Then _
> .Offset(-10, 0).Resize(10, 8).Copy Destination:= _
> .Cells
> End With
> End Sub
>
> This uses the active cell, and, as long as it's in Row 11 or higher,
> copies the 10 rows above it (and 8 columns wide) to the activecell.
>
> The "." are shorthand for the object that follows the "With" (i.e.,
> ActiveCell).
>
> Notice that it avoids making any Selections - using the Range
> objects directly (in this case ActiveCell and the ranges derived
> from it) makes your code smaller, faster, and IMO easier to maintain.
>
>
> BTW - most regulars read .misc, .worksheet.functions and
> .programming, so, while cross-posting isn't nearly as bad as posting
> individual messages to different groups, it's largely not necessary.
>
>
>
> In article <3effdfa3$0$26637$(E-Mail Removed)>,
> "Shiraz Mistry" <(E-Mail Removed)> wrote:
>
> > Hi all,
> >
> > I want to position my cursor in a cell (in Column A) and press a macro
> > button to fill in the rest of the week.
> >
> > For example, cell A91 should fill the rest of the week as the above

week,
> > that is, A81:H89.
> >
> > Currently, this is the code for the table-
> >
> > Sub Table()
> > '
> > ' Table Macro
> > ' Macro recorded 6/24/03 by Shiraz Mistry
> > '
> > '
> > Range("A71:H79").Select
> > Selection.Copy
> > Range("A81").Select
> > ActiveSheet.Paste
> > Application.CutCopyMode = False
> > End Sub
> > I know it has something to do with the above range:
> >
> > Range("A81").Select
> >
> > but I am not sure what and how to change this line.
> >
> > I can send the workbook to people that may be interested.
> >
> > Any help would be appreciated,
> >
> > Thanks,
> >
> > Shiraz J. Mistry
> >
> >
> >



 
Reply With Quote
 
Clarke Rice
Guest
Posts: n/a
 
      30th Jun 2003
Folks,

I recieved the following query from my gf this morning - and have no idea
how it is done. She's recently change job, old textbooks are in transit
and new employer hasn't set her up for newsgroups.

All help appreciated - if you are posting can you also mail me please -
clarke w rice At yahoo dot co dot uk

Thanks

---
I'm fiddling with Visual Basic [Excel] and I now don't have my trusty VB
textbook I had in old office and help files aren't installed in this
computer.

What I'm trying to do is have a combobox linked to a cell and then have a
command box I click on and whatever name is in linked cell I'm takien to a
certian cell within spreadsheet eg If A12 = Mike then take me to cell A20.

I canget the IF = bit, but I'm having trouble with 'take me to this cell
bit' and as help files aren't installed here can u have a alook for me on
your PC and let me know? Ta muchly !





--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Macro to export table to Excel then run Excel macro Craig Microsoft Access Macros 1 14th Mar 2009 03:44 AM
Importing excel table but user to select table in macro Tiffany Microsoft Access External Data 4 22nd Oct 2008 04:32 AM
Excel 2007 Macro specific table to generic table? Sue Microsoft Excel Misc 3 1st Jun 2008 07:12 PM
How do I Append excel data to a Access database table in a excel macro? Pete Microsoft Excel Programming 1 2nd Nov 2005 07:40 PM
Excel table macro Shiraz Mistry Microsoft Excel Misc 3 30th Jun 2003 11:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:47 PM.