473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VBA loop copy and paste

I need a loop that goes does column B4: B20 and finds a date and copies the data adjacent in C4: c20 until the end date in different cells

Start date is in F3, and end date in F4: In rows b are months ie: 1/1/2002, 2/1/2002 etc.
Row C consists of data (300, 200 etc).

Expand|Select|Wrap|Line Numbers
  1. dim x as string, dim y as string
  2. Dim found as boolean
  3.  
  4. 'where the user puts in the start date and the loop will go and find it in rows b
  5. x=worksheets("sheet2").range (f3") 
  6. 'the end date which the user enters
  7. y=worksheets("sheet2").range("f4")
  8.  
  9. 'selecting the start of the data
  10. Range("b5").select
  11. 'running the loop, or at least I am trying too
  12.  
  13. Do until Isempty(activecell)
  14.    If activecell.value=x then
  15. found=true
  16. exit do
  17. end if
  18. 'selects the bottom cell and keeps going down to search "x"
  19. activecell.offset(1,0).select
  20. loop
  21. If found=true then
  22. 'when the date is found it copies the adjacent cell
  23. activecell.offset(0,1).copy
  24. end if

Where I am having trouble is pasting the cell, and then continuing the loop until the other date is reached which is ("Y")-y=worksheets("sheet2").range("f4")


Please let me know if you can help
Oct 17 '10 #1
1 1685
Guido Geurs
767 Expert 512MB
This will work:
Run through the data and put the results in an array.
Dump this array later in the sheet on the right place.
Do you need help with this ?
If so, is it possible to attach in Bytes a sheet so we can work on the same data ? (if to big, just ad a part of the data).
If possible, attach also an example how the final result must look like.
Oct 18 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: The Flyer | last post by:
Hi Sorry for posting this message to so many groups, but I was not sure which group the windows keyboard experts would be reading, so I ventured to post it to all of them. I want to map or...
3
by: Faith | last post by:
Hello. I need to take a column from Excel(unknown amount of rows) that will be selected by the user and copy those cells. Then I will need to paste those cells into the first column in a Data...
4
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
3
by: Rachel Suddeth | last post by:
This may not be the right forum, but it's a problem I chiefly come across when trying to post here. When I do a copy/paste from VS, the text always looks really weird (and even if I'm in an...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: NetronProject | last post by:
My copy/paste operation results in a MemoryStream full of '\0' characters on the Clipboard. Maybe my approach to copy/paste is wrong when handling generic types. All entries in the CollectionBase...
0
by: squirrelonfire | last post by:
Hi I run postgreSQL from a remote server like this SSH -X cnguyen_db@okaram.spsu.edu ....enter the password Then I run bluefish& and psql The problem I'm having is that I can't copy and paste...
2
by: al_johnson222 | last post by:
>From any page, I want to be able to call a JS function that will do the equivelant of select all, and copy. This data will then be posted to a page that will log it. This would be easy using...
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
3
by: questionit | last post by:
Some websites disable the Windows copy and paste feature to use on thier website. A text can not be copied and pasted either from using shortcuts : CTRL+C, CTRL+V or from using copy, paste option...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.