VBA Code to extract data between dates.

Niveditha

New Member
Joined
Feb 4, 2016
Messages
10
Hi All,

This is the requirement I have and it would be really helpful if someone can help me here.

1) Sheet1 in excel has 13 columns. I need to extract columns B,J and L to sheet 2.
2) Column B can be copied directly. But, column J is sort of like a history update and the matter would look somewhat like this:
2/8- blah1 blah1 blah1 blah1 2/7-blah blah2 blah2 2/6- blah3 blah3

3)I would need only the latest date and the text that follows it to be copied to next sheet. I also need to append something like "ABC says:-" after the date.

ie., in my sheet 2, I would have column B as 2/8- ABC says:- blah1 blah1 blah1 blah1

I'm a Beginner in macros and excel and any help would be greatly appreciated!!! :)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
when you say you need to extract column B,J and L to sheet 2, do they need to be in the same column, or in A,B and C?
 
Upvote 0
Thanks for responding dermie!

Its copied from B, J and L in sheet 1 to to A,B,C in sheet 2.

Should have made that clear earlier. My bad.
 
Upvote 0
the following code will copy the columns across.
Code:
Sub niveditha()
Sheets("Sheet2").Range("B:B,J:J,L:L").Copy Destination:=Sheets("Sheet1").Range("A1")
End Sub
what determines the dates that you will need to capture. Is the blah blah blah's you mentioned dates or text? Does the same apply for column C (the old column L)?
 
Upvote 0
Hi dermie,

Thank you for helping out :)

To provide a broader picture,

Sheet 1 --> Column K has a date field . I initially do a manual filter on this field and check only the latest date. So now I'm left with lesser number of rows.
Next I need to copy all data from columns B,J and L to sheet 2 ( columns A, B,C)
B and L in sheet 1 can be copied directly to A and C respectively in sheet 2.

Column J in sheet 1-->
2/8- My name is Niveditha. Im new to excel. 2/7- I said on 2/8 that I'm curious to learn macros. 2/6- Anything can come as a content here.

Column C in sheet 2-->
2/8- ABC says-My name is Niveditha. Im new to excel.
 
Upvote 0
Just to add on, basically I require only the latest update and not the history updates/previous conversations.
The filter I would have applied initially in this example on column K would be 2/8.
 
Upvote 0
I initially do a manual filter on this field and check only the latest date.

If you were to run the report today, what dates would you select?

Coding the autofilter with a date variant shouldn't be too hard, just need to know what dates are selected and why
 
Upvote 0
If you were to run the report today, what dates would you select?

Coding the autofilter with a date variant shouldn't be too hard, just need to know what dates are selected and why

I would be selecting the max date from column K. Ideally, when I open the excel on 10th, the max date in column K would be 9. So I would chose Feb 9 and then do the remaining copy column operations..
 
Upvote 0
basically, I intend to select the latest date from column K. It does have timestamp appended to it. So I would want all entries for that particular date, irrespective of timestamp. ( 2/9/2016 2:30 PM and 2/9/2016 5:30 PM are both needed )
 
Upvote 0
Hoping if someone can help me out here :(
Please do let me know if I should provide anymore details!

Thanks in advance!!! :)
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,793
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top