Writing Data with a macro???

T

Ted

I'm trying to create a macro that but it keeps returning to the same cell.
How can I change it to run from whatever cell I'm in?

Sub Medford()
'
' Medford Macro
' Macro recorded 1/3/2009 by ted
'
' Keyboard Shortcut: Ctrl+m
'
ActiveCell.FormulaR1C1 = "Medford"
Range("C4").Select
ActiveCell.FormulaR1C1 = "250"
Range("B4").Select
Selection.EntireRow.Insert
End Sub
Sub Porland()
'
' Portland Macro
' Macro recorded 1/3/2009 by ted
'
' Keyboard Shortcut: Ctrl+p
'
ActiveCell.FormulaR1C1 = "Portland"
Range("C4").Select
ActiveCell.FormulaR1C1 = "54"
Range("B4").Select
Selection.EntireRow.Insert
End Sub
 
D

Dave Peterson

How about describing what you want to do?

Change the activecell to some text.
Move up/down xx rows and right/left yy columns and change that cell.
Then move ...

C4 and B4 don't add much information to where things should go.

With activecell
.value = "Medford"
.offset(3,5).value = 250
.offset(2,0).entirerow.insert
end with

But those .offset() numbers aren't right (except by coincidence).

They first number is the number of rows (down if positive, up if negative) and
the second number is the number of columns (positive=right, negative=left).

Maybe you can figure out what you need????
 
T

Ted

I want to jump from cell to cell in the colum and fill the cell with data
for a expense report


Medford 250
Portland 150
Ashlans 175
Medford 250
Medford 250
Medford 250
Portland 150

So if I keep hitting clt+m or what ever, it dosn't matter what cell I'm in
 
T

Ted

ctl+m
Medford 250
ctl+p
PortLand 150
ctl+a
Ashland 275



So I can go to any cell and use the Macro to fill with data
 
D

Dave Peterson

Sub Medford()
With activecell
.value = "Medford"
.offset(0,1).value = 250
end with
End Sub

will plop Medford into the activecell and 250 in the cell to the right.
 
T

Ted

Thanx that got. I just adde in the insert row.

I'll be reading up on how that works.
 

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