Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Trying to write a macro

I am trying to write a macro that begins a search about 45 rows from the top
of a spreadsheet. It will search column D for cells that not empty. When it
finds one, the macro should copy a coresponding value in column F and place
that value on another page in my workbook. This process needs to loop until
all non empty cells in column D have their corresponding column F values
copied and pasted. The problem is that I'm not very good with VBA or macros?
Can you help with this?

Thanks in advance and have a great day.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Trying to write a macro

Hi John

let's give it a try
first of all, we need a loop, which loops 45 times, corresponding to the
rows you want to search through:

for i = 1 to 45

next i

after that we need to check if in this row the cell in column D is empty so
inside of the loop:

if cells(i, 4).formular1c1 = "" then

end if

now if the code finds a empty cell we have to enter data to the column f so
inside of the if:

cells(i,6).formular1c1 = "Whatever you like"

and now you want to put a value on another sheet:

sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or whatever"

so the final code will look something like this

for i = 1 to 45
if cells(i, 4).formular1c1 = "" then
cells(i,6).formular1c1 = "Whatever you like"
sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or
whatever"
end if
next i

hth, otherwise, just ask

Carlo
"john mcmichael" wrote:

I am trying to write a macro that begins a search about 45 rows from the top
of a spreadsheet. It will search column D for cells that not empty. When it
finds one, the macro should copy a coresponding value in column F and place
that value on another page in my workbook. This process needs to loop until
all non empty cells in column D have their corresponding column F values
copied and pasted. The problem is that I'm not very good with VBA or macros?
Can you help with this?

Thanks in advance and have a great day.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Trying to write a macro

Carlo,

This is GREAT!! and it will definately help my overall VBA base of
info...but I can use a bit more if you can spare the time. In this particular
search, I'm not looking for empty cells in column D but cells that have
values already in place ( any value, not something specific ) and then I need
to copy a second number in the same row that is 2 columns to the right to
place on the other sheet. It is almost like a VLOOKUP but w/o specifying
what values to find. Thanks again. Your help very much appreciated.

"Carlo" wrote:

Hi John

let's give it a try
first of all, we need a loop, which loops 45 times, corresponding to the
rows you want to search through:

for i = 1 to 45

next i

after that we need to check if in this row the cell in column D is empty so
inside of the loop:

if cells(i, 4).formular1c1 = "" then

end if

now if the code finds a empty cell we have to enter data to the column f so
inside of the if:

cells(i,6).formular1c1 = "Whatever you like"

and now you want to put a value on another sheet:

sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or whatever"

so the final code will look something like this

for i = 1 to 45
if cells(i, 4).formular1c1 = "" then
cells(i,6).formular1c1 = "Whatever you like"
sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or
whatever"
end if
next i

hth, otherwise, just ask

Carlo
"john mcmichael" wrote:

I am trying to write a macro that begins a search about 45 rows from the top
of a spreadsheet. It will search column D for cells that not empty. When it
finds one, the macro should copy a coresponding value in column F and place
that value on another page in my workbook. This process needs to loop until
all non empty cells in column D have their corresponding column F values
copied and pasted. The problem is that I'm not very good with VBA or macros?
Can you help with this?

Thanks in advance and have a great day.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Trying to write a macro

Ah ok, so the value you want to copy is the value in the column F.

Ok, then it will look like this:

for i = 1 to 45
if cells(i, 4).formular1c1 < "" then
'< means not equal to, so it takes every cell which has something in it.
sheets("yourotherpage").cells(x,y).formular1c1 = cells(i,6).formular1c1
'x and y are the coordinates for your destination on the other sheet
end if
next i

hth......otherwise just call

Cheers Carlo

"john mcmichael" wrote:

Carlo,

This is GREAT!! and it will definately help my overall VBA base of
info...but I can use a bit more if you can spare the time. In this particular
search, I'm not looking for empty cells in column D but cells that have
values already in place ( any value, not something specific ) and then I need
to copy a second number in the same row that is 2 columns to the right to
place on the other sheet. It is almost like a VLOOKUP but w/o specifying
what values to find. Thanks again. Your help very much appreciated.

"Carlo" wrote:

Hi John

let's give it a try
first of all, we need a loop, which loops 45 times, corresponding to the
rows you want to search through:

for i = 1 to 45

next i

after that we need to check if in this row the cell in column D is empty so
inside of the loop:

if cells(i, 4).formular1c1 = "" then

end if

now if the code finds a empty cell we have to enter data to the column f so
inside of the if:

cells(i,6).formular1c1 = "Whatever you like"

and now you want to put a value on another sheet:

sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or whatever"

so the final code will look something like this

for i = 1 to 45
if cells(i, 4).formular1c1 = "" then
cells(i,6).formular1c1 = "Whatever you like"
sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or
whatever"
end if
next i

hth, otherwise, just ask

Carlo
"john mcmichael" wrote:

I am trying to write a macro that begins a search about 45 rows from the top
of a spreadsheet. It will search column D for cells that not empty. When it
finds one, the macro should copy a coresponding value in column F and place
that value on another page in my workbook. This process needs to loop until
all non empty cells in column D have their corresponding column F values
copied and pasted. The problem is that I'm not very good with VBA or macros?
Can you help with this?

Thanks in advance and have a great day.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Trying to write a macro

Hey again Carlo,

I have typed the macro code :) and checked and double checked it. I get a
run time error 13 whenever I attempt to run it. :( Since I'm bothering you
again. Does this code ( sheets("yourotherpage").cells(x,y).formular1c1 =
cells(i,6).formular1c1 ) specify that the data will be copied into cell (x,y
) as in beggining with cell A1 where x=A and y=1 and then each additional
piece of data will end up below as in B1, C1, etc? Thanks very much, I'm
trying to make sure I understand.



"Carlo" wrote:

Ah ok, so the value you want to copy is the value in the column F.

Ok, then it will look like this:

for i = 1 to 45
if cells(i, 4).formular1c1 < "" then
'< means not equal to, so it takes every cell which has something in it.
sheets("yourotherpage").cells(x,y).formular1c1 = cells(i,6).formular1c1
'x and y are the coordinates for your destination on the other sheet
end if
next i

hth......otherwise just call

Cheers Carlo

"john mcmichael" wrote:

Carlo,

This is GREAT!! and it will definately help my overall VBA base of
info...but I can use a bit more if you can spare the time. In this particular
search, I'm not looking for empty cells in column D but cells that have
values already in place ( any value, not something specific ) and then I need
to copy a second number in the same row that is 2 columns to the right to
place on the other sheet. It is almost like a VLOOKUP but w/o specifying
what values to find. Thanks again. Your help very much appreciated.

"Carlo" wrote:

Hi John

let's give it a try
first of all, we need a loop, which loops 45 times, corresponding to the
rows you want to search through:

for i = 1 to 45

next i

after that we need to check if in this row the cell in column D is empty so
inside of the loop:

if cells(i, 4).formular1c1 = "" then

end if

now if the code finds a empty cell we have to enter data to the column f so
inside of the if:

cells(i,6).formular1c1 = "Whatever you like"

and now you want to put a value on another sheet:

sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or whatever"

so the final code will look something like this

for i = 1 to 45
if cells(i, 4).formular1c1 = "" then
cells(i,6).formular1c1 = "Whatever you like"
sheets("yourotherpage").cells(x,y).formular1c1 = "Something else or
whatever"
end if
next i

hth, otherwise, just ask

Carlo
"john mcmichael" wrote:

I am trying to write a macro that begins a search about 45 rows from the top
of a spreadsheet. It will search column D for cells that not empty. When it
finds one, the macro should copy a coresponding value in column F and place
that value on another page in my workbook. This process needs to loop until
all non empty cells in column D have their corresponding column F values
copied and pasted. The problem is that I'm not very good with VBA or macros?
Can you help with this?

Thanks in advance and have a great day.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a macro JStiehl Excel Discussion (Misc queries) 4 August 11th 08 10:08 PM
how do i write a macro AB Excel Worksheet Functions 1 August 17th 06 08:47 PM
How to write a macro to do... marg Excel Programming 1 July 17th 06 08:20 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
How do I write a macro for... Christopher Anderson Excel Discussion (Misc queries) 1 December 20th 04 05:18 PM


All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"