CUT AND PASTE (FORMULA WITH CONCATENATE)?

rhwebb

New Member
Joined
Jan 10, 2022
Messages
18
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
1642485052082.png


Need some help from the VBA gurus please. I'm working on a project (simplified here) in which I need to remove the text in cell F2:J2 (merged). The data within that cell will then be placed into cell A3:J3 (merged). However I do not need the entire text/date string-- only "Report Date: dd - mmm - yyyy". I'm looking either for a VBA solution to cut and paste which will isolate that text string (variable date) or a formula to CONCATENATE "Report Date:" with Today(). When I tried to write an ActiveCell.FormulaR1C1= i received an error for expected end. Would really appreciate any help.

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I need to remove the text in cell F2:J2 (merged). The data within that cell will then be placed into cell A3:J3 (merged). However I do not need the entire text/date string-- only "Report Date: dd - mmm - yyyy".
See if this does what you want

VBA Code:
Sub Report_Date()
  With Range("F2")
    Range("A3").Value = Mid(.Text, InStr(1, .Text, "Report"))
    .MergeArea.ClearContents
  End With
End Sub
 
Upvote 0
See if this does what you want

VBA Code:
Sub Report_Date()
  With Range("F2")
    Range("A3").Value = Mid(.Text, InStr(1, .Text, "Report"))
    .MergeArea.ClearContents
  End With
End Sub
Thank you for the help. Unfortunately I could not get this to return the correct result. Instead of cutting and pasting the Report Date: xx xxx xxxx it copied the "personnel report" text from row 2 and placed it in row 3. So now my text is (row 2) 'personnel report', (row 3) 'personnel report'. Both rows are merged and centered which is good. I just need row 3 to have the following text "Report Date: dd - mmm - yyyy". Close but no joy yet.
 
Upvote 0
Yes, but I'm trying to move the text in F2:J2 down to A3
 
Upvote 0
My code does not reference A2:E2 at all. Something must be different about your sheet set-up to mine, or else you may have modified the code?

Here is my sheet before running the code

rhwebb_1.xlsm
ABCDEFGHIJ
1HEADER
2Personnel ReportSource: database Report Date: 17 - Jan - 2022
3
4FOOTER
Sheet3


.. and after:

rhwebb_1.xlsm
ABCDEFGHIJ
1HEADER
2Personnel Report
3Report Date: 17 - Jan - 2022
4FOOTER
Sheet3



Is that what you are wanting?
 
Upvote 0
Very close. I'm hoping for row 2 to be centered as well. Thank you for all of the trouble.
 
Upvote 0
Did you work out what was going wrong before?

In any case, try this

VBA Code:
Sub Report_Date_v2()
  With Range("F2")
    Range("A3").Value = Mid(.Text, InStr(1, .Text, "Report"))
    .MergeArea.ClearContents
  End With
  Range("A2:J2").Merge
End Sub
 
Upvote 0
Yes! I found some code in the original project that I was able to "switch off". That was causing the hang up. Last question. In the code you gave me it was for a text string starting (MID) cell and all text after that. For future reference, how do I keep only part of a string instead of all text past a certain word? I.e. if I only wanted two words "Report Date" instead of "Report Date: dd mmm yyyy".
 
Upvote 0
if I only wanted two words "Report Date" instead of "Report Date: dd mmm yyyy".
How to extract text depends on individual circumstances. It would depend on what variations of text could be in the original cell and what "rule" you want to apply to extract part of that text.
You would need to give a variety of examples of the original text together with the desired result for each to make a suitable suggestion.
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,953
Members
449,198
Latest member
MhammadishaqKhan

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