Copy specific cells of multiple rows in Sheet1 depending on the date in column A and pasting it in specific cells in sheet2

Pascal_Wyss

New Member
Joined
Dec 1, 2017
Messages
10
Hello Everyone,

As a standard opening remark i want to say that I am an absolute VBA newcomer and have very little idea of coding. That sad, it is a pretty big task for mi that I have in hand. So I am most grateful of any and all help given!!!

My problem is as follows:

In Sheet1 I have a Table containing Date of the patient visit (Todays Date), patient name, treatment and pricing among other data. So basically, every patient arriving gets a new row.
I need to create a button (macro) that is able to identify the range of patients that visited today and copy specific cells of all the rows containing todays date in sheet1.

For example: From row 221 to row 275 are patients with today’s date, from these patients I need to copy content of column A,B,D,E,H,I and paste the values in sheet2 in the first free row. But the catch is that the columns are not in the same sequence. So content from column A goes in to B and B in to H… etc.

I hope that my description is understandable.

As it would be difficult to attach an example as it is a live workbook containing confidential data.

I thank you all in advanced for your efforts.
With best regards
Pascal
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hello Everyone,

As a standard opening remark i want to say that I am an absolute VBA newcomer and have very little idea of coding. That sad, it is a pretty big task for mi that I have in hand. So I am most grateful of any and all help given!!!

My problem is as follows:

In Sheet1 I have a Table containing Date of the patient visit (Todays Date), patient name, treatment and pricing among other data. So basically, every patient arriving gets a new row.
I need to create a button (macro) that is able to identify the range of patients that visited today and copy specific cells of all the rows containing todays date in sheet1.

For example: From row 221 to row 275 are patients with today’s date, from these patients I need to copy content of column A,B,D,E,H,I and paste the values in sheet2 in the first free row. But the catch is that the columns are not in the same sequence. So content from column A goes in to B and B in to H… etc.

I hope that my description is understandable.

As it would be difficult to attach an example as it is a live workbook containing confidential data.

I thank you all in advanced for your efforts.
With best regards
Pascal

What i have so far been experimenting with is:

Code:
Sheets("Pacientes y Tratamiento").Select
    
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Dim c As Range
    For Each c In Range("A5:A" & bottomA)
        If c = Date Then
            Cells(c.Row, "A").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "A5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
            Cells(c.Row, "B").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "D5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
            Cells(c.Row, "D").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "C5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
            Cells(c.Row, "E").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "E5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
            Cells(c.Row, "H").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "K5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
            Cells(c.Row, "I").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "F5").End(xlUp).Offset(1, 0).PasteSpecial x1PasteValue
        End If
    Next c
    Application.ScreenUpdating = True


End Sub

However it gives me a series of errors!
 
Upvote 0
Hi & welcome to the board.
Couple of things that I've noticed
Here
Code:
Cells(Rows.Count, "A5")
you need to remove the number, leaving "A" (the same for the other 5 copies).
Also you have x1PasteValue which should be xlPasteValues note the s on the end and the lowercase L, rather than a numeric one.
 
Upvote 0
Dear Fluff,

Thank you so much for your reply. It is very much appreciated.

My code now looks like this:

Code:
Sub CierreDia()


Sheets("Pacientes y Tratamiento").Select
    
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Dim c As Range
    For Each c In Range("A5:A" & bottomA)
    
        If c = Date Then
            Cells(c.Row, "A").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "B").End(xlUp).PasteSpecial xlPasteValues
            Cells(c.Row, "B").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "D").End(xlUp).PasteSpecial xlPasteValues
            Cells(c.Row, "D").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "C").End(xlUp).PasteSpecial xlPasteValues
            Cells(c.Row, "E").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "E").End(xlUp).PasteSpecial xlPasteValues
            Cells(c.Row, "H").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "K").End(xlUp).PasteSpecial xlPasteValues
            Cells(c.Row, "I").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "F").End(xlUp).PasteSpecial xlPasteValues
        End If
    Next c
    Application.ScreenUpdating = True


End Sub

It however does not what I need it to do. I doesn't give me back an error code eater. So I don't know what exactly is wrong.

I can see that he goes to the "Sheets("Pacientes y Tratamiento").Select" but he doesn't do nothing from there. I am desperate.....

If you could assist me further it would litteraly save me.

Thank you!

With best regards
Pascal
 
Upvote 0
You've removed this
Code:
.Offset(1, 0)
from your original code. It needs to go back in, otherwise you'll just be overwriting data, rather than adding it to the next row.
 
Upvote 0
I am an absolute VBA newcomer and have very little idea of coding. That sad, it is a pretty big task for mi that I have in hand. So I am most grateful of any and all help given!!!

Pascal_Wyss,

Welcome to the MrExcel forum.


See if something, in the below link(s), of my most up to date list will help you:

Training / Books / Sites as of 11/29/2017

What Is VBA?
https://www.techwalla.com/articles/what-is-vba

MrExcel's Products: Books, CDs, Podcasts Discuss topics related to Holy Macro! Products: Learn Excel from MrExcel, VBA and Macros for Microsoft Excel,Holy Macro! It's 2500 VBA Examples CD, Guerilla Data Analysis Using Microsoft Excel and Excel Knowledge Base CD and the MrExcel Podcasts.
http://www.mrexcel.com/forum/mrexcels-products-books-cds-podcasts/
http://www.mrexcel.com/store/index.php?l=product_detail&p=306

There are over 1800 Excel videos/tutorials here:
http://www.youtube.com/user/ExcelIsFun

Getting Started with VBA.
http://www.datapigtechnologies.com/ExcelMain.htm

If you are serious about learning VBA try
http://www.add-ins.com/vbhelp.htm

Excel Tutorials and Tips - VBA - macros - training
http://www.mrexcel.com/articles.shtml

MrExcel's Excel Tutorial Listing
http://www.mrexcel.com/articles.shtml

[VBA] Difference between OLEFormat and ControlFormat?
For references purposes and excellent explanations, see
http://wellsr.com/vba/excel/#guides

Excel VBA MACRO Kick-start Course for absolute beginner

Free VBA Course
http://www.excel-pratique.com/en/vba.php

Excel 2007 VBA materials to learn here:
http://www.worldbestlearningcenter.com/index_files/excel-VBA-understanding.htm

The macro recorder actually is your friend but look here:
http://www.tushar-mehta.com/excel/vba/beyond_the_macro_recorder/

Introduction to Variables, Constants and Data Types
http://msdn.microsoft.com/en-us/library/aa242127(v=vs.60).aspx

Declaring Variables
http://www.cpearson.com/excel/declaringvariables.aspx

Here's a good primer on the scope of variables.
http://www.cpearson.com/excel/scope.aspx
Variable Scope in Excel VBA - EASY Excel Macros
Understanding Scope

Using Variables in Excel VBA Macro Code
http://www.ozgrid.com/VBA/variables.htm

See David McRitchie's site if you just started with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

What is a VBA Module and How is a VBA Module Used?
http://www.emagenit.com/VBA Folder/what_is_a_vba_module.htm

Events And Event Procedures In VBA
http://www.cpearson.com/excel/Events.aspx

Here is a good introductory tutorial using a VBA Class:
http://www.cpearson.com/excel/classes.aspx

There's a chapter on classes in VBA Developer's Handbook which is also good.
http://www.amazon.com/VBA-Developers-Handbook-2nd-Edition/dp/0782129781

Ron's Excel Tips
http://www.rondebruin.nl/tips.htm

Ron de Bruin's Mail from Excel and make/mail PDF files (Windows)
http://www.rondebruin.nl/win/section1.htm

How do I create and use a PERSONAL file for my VBA code
http://www.rondebruin.nl/win/personal.htm

Anthony's Excel VBA Page - Excel Application - Excel Consultant - Excel Consulting (see 3 tutorials in Excel VBA Basic Tutorial Series)

BET: Microsoft Excel Visual Basic

Debugging VBA
http://www.cpearson.com/Excel/DebuggingVBA.aspx

Debug Excel VBA Macro Code
http://www.ozgrid.com/VBA/debug.htm

TechBookReport - Debugging Excel VBA Code
http://www.techbookreport.com/tutorials/debug_excel_vba_01.html

Here are some general links on performance improvement:
https://www.soa.org/News-and-Publica...s42-roper.aspx
Optimize Slow VBA Code. Speed Up Efficient VBA Code/Macros
Excel VBA Performance Coding Best Practices - Office Blogs
https://msdn.microsoft.com/en-us/library/aa730921.aspx

Start at the beginning...

Creating An XLA Add-In For Excel, Writing User Defined Functions In VBA
http://www.cpearson.com/excel/createaddin.aspx

Build an Excel Add-In
http://www.fontstuff.com/vba/vbatut03.htm

Creating custom functions
http://office.microsoft.com/en-us/excel/HA011117011033.aspx

Writing Your First VBA Function in Excel
http://www.exceltip.com/st/Writing_Your_First_VBA_Function_in_Excel/631.html

VBA for Excel (Macros)
http://www.excel-vba.com/excel-vba-contents.htm

Excel Macros Tutorial
http://www.excel-vba.com/excel-vba-contents.htm

Excel Macros & Programming
http://www.excel-vba.com/index.htm

VBA Lesson 11: VBA Code General Tips and General Vocabulary
http://www.excel-vba.com/vba-code-2-1-tips.htm

Excel VBA -- Adding Code to a Workbook
http://www.contextures.com/xlvba01.html

Beyond Excel's recorder

Helpful as a simple concise reference for the basics, and, using the macro recorder is endlessly powerful.
http://www.techonthenet.com/excel/cells/index.php

Learn to debug:
http://www.cpearson.com/excel/debug.htm

How To: Assign a Macro to a Button or Shape
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/

User Form Creation
http://www.contextures.com/xlUserForm01.html

Build a UserForm for Excel
http://www.fontstuff.com/ebooks/free/fsuserforms.pdf

When To Use a UserForm & What to Use a UserForm For
http://www.ozgrid.com/Excel/free-training/ExcelVBA2/excelvba2lesson2.htm

UserForms in Excel VBA - UserForm Basics; Add Controls dynamically at run-time using the Add Method; UserForm Controls (A Snapshot)

Excel VBA how to Personalise the Ribbon
http://www.bing.com/videos/search?q...l+vba+how+to+Personalise+the+Ribbon&FORM=VDRE

Excel Tutorials / Video Tutorials - Functions
http://www.contextures.com/xlFunctions02.html

How to insert Buttons, radio buttons and check boxes in Excel
http://www.bing.com/videos/search?q...io+buttons+and+check+boxes+in+Excel&FORM=VDRE

INDEX MATCH - Excel Index Function and Excel Match Function
http://www.contextures.com/xlFunctions03.html

Multi or two way vlook up and index match tutorial
http://www.get-digital-help.com/

Excel Data Validation
http://www.contextures.com/xlDataVal08.html#Larger
http://www.contextures.com/excel-data-validation-add.html

Excel -- Data Validation -- Create Dependent Lists
http://www.contextures.com/xlDataVal02.html

http://www.get-digital-help.com/201...s-containing-unique-distinct-values-in-excel/

Your Quick Reference to Microsoft Excel Solutions
http://www.xl-central.com/index.html

New! Excel Recorded Webinars
http://www.datapigtechnologies.com/ExcelMain.htm

MS Excel: VBA Functions - Listed by Category
MS Excel: ALL Formulas/Functions - Listed by Category

Fuzzy Matching - new version plus explanation
http://www.mrexcel.com/forum/excel-questions/195635-fuzzy-matching-new-version-plus-explanation.html

Programming The VBA Editor - Created by Chip Pearson at Pearson Software Consulting LLC
This page describes how to write code that modifies or reads other VBA code.
http://www.cpearson.com/Excel/vbe.aspx

VBA and Macros for Microsoft Excel, by Bill Jelen "Mr.Excel" and Tracy Syrstad

Excel Hacks 100 Industrial-Strength Tips & Tools, by David & Traina Hawley

VBA and Macros for Microsoft Excel 2007, by Bill Jelen "Mr.Excel" and Tracy Syrstad

John Walkenbach's power programming with Excel books.

Excel 2010 Power Programming with VBA, Mr. Spreadsheet's Bookshelf

by Stephen/ Bovey, Rob/ Green, John Bullen (Paperback - Feb 11, 2005)
Professional Excel Development

by Rob Bovey, Stephen Bullen, John Green, and Robert Rosenberg (Paperback - Sep 26, 2001)
Excel 2002 VBA: Programmers Reference

Professional Excel Development by Rob Bovey, Dennis Wallentin, Stephen Bullen, & John Green

DonkeyOte: My Recommended Reading, Volatility
http://www.decisionmodels.com/calcsecretsi.htm

A list of Reference Books
http://www.andypope.info/books/books.htm

Sumproduct
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

Need to understand error handling
http://www.cpearson.com/excel/errorhandling.htm

Excel file error message
How to diagnose Excel file corruption and repair workbooks

If a file cannot be repaired, consider recovering an earlier version from your file history
https://support.microsoft.com/en-us/...8-file-history

Arrays
http://www.mrexcel.com/forum/excel-questions/390246-vba-array-basics.html
http://www.cpearson.com/excel/VBAArrays.htm
http://www.xtremevbtalk.com/showthread.php?t=296012
http://www.vbtutor.net/vba/vba_chp21.htm
http://excelmacromastery.com/Blog/index.php/the-complete-guide-to-using-arrays-in-excel-vba/

Array Dimensions in Visual Basic - Working with Dimensions (code and graphics)
http://msdn.microsoft.com/en-us/library/02e7z943(v=VS.80).aspx

Visual Basic Array Tutorial written by Adam Wehmann
http://patorjk.com/programming/tutorials/vbarrays.htm

Shortcut Keys in Excel 2000 through 2007

Pivot Intro
http://peltiertech.com/Excel/Pivots/pivotstart.htm
Office 2010 Class #36: Excel PivotTables Pivot Tables 15 examples (Data Analysis) - YouTube
http://www.youtube.com/watch?v=qMGILHiLqr0
Getting Started with Pivot Tables
http://www.contextures.com/xlPivot01.html#Start
Overview of PivotTable and PivotChart reports
http://office.microsoft.com/en-gb/e...table-and-pivotchart-reports-HP010342752.aspx
Build a Pivot Table in Excel VBA
http://www.brainbell.com/tutorials/Excel_VBA/Build_A_Pivot_Table_In_Excel_VBA.html

Excel 2013 PowerPivot Basics #01: Introduction To PowerPivot for Excel 2013 - YouTube

Conditional Formatting
http://office.microsoft.com/en-001/...apply-conditional-formatting-HA102809768.aspx

Count cells based on Conditional Formatting color?
http://www.cpearson.com/Excel/CFColors.htm
http://www.excelfox.com/forum/showt...-(whether-from-Conditional-Formatting-or-not)
https://stackoverflow.com/questions...-of-a-conditionally-formatted-cell-in-excel-2

Email from XL - VBA
http://www.rondebruin.nl/sendmail.htm

Outlook VBA
https://www.rondebruin.nl/win/section1.htm
http://www.outlookcode.com/article.aspx?id=40
Exporting Email Body Text to excel (using outlook 2010) VBA
Exporting text from body of outlook email to excel
Quickly export Outlook e-mail items to Excel - TechRepublic

Mail a message to each person in a range
http://www.rondebruin.nl/win/s1/outlook/bmail5.htm

Excel VBA Dictionary – A Complete Guide
https://excelmacromastery.com/vba-dictionary/

Excel Function Dictionary by Peter Noneley
http://www.xlfdic.com/
http://www.hoffits.com/

Function Translations
http://www.piuha.fi/excel-function-name-translation/

Dynamic Named Ranges
http://www.contextures.com/xlNames01.html

Vba to create waterfall charts
http://peltiertech.com/excel-waterfall-charts-bridge-charts/

How to create Excel Dashboards
http://www.contextures.com/excel-dashboards.html
http://chandoo.org/wp/excel-dashboards/
http://chandoo.org/wp/management-dashboards-excel/
http://www.exceldashboardwidgets.com/
http://www.andypope.info/charts/gauge.htm
https://exceldashboardschool.com/
https://www.youtube.com/user/OnLinePCLearning/featured

To create my Dashboard I use this small ebook: Create a Dashboard using PivotTable - Roger F. Silva
https://www.amazon.com/Create-Dashb...?s=digital-text&ie=UTF8&qid=1486600546&sr=1-3

Excel Dashboard / Scorecard Ebook
http://www.qimacros.com/excel-dashboard-scorecard.html

Free dashboard training materials
https://www.google.com.hk/search?q=...rome..69i57.2835j0j8&sourceid=chrome&ie=UTF-8
https://www.youtube.com/user/OnLinePCLearning/featured

Excel Dashboard School
https://exceldashboardschool.com/

Mike Alexander from Data Pig Technologies
http://www.amazon.com/Excel-2007-Da...=sr_1_1?s=books&ie=UTF8&qid=1305564958&sr=1-1

Templates
http://www.cpearson.com/Excel/Topic.aspx
http://www.contextures.com/excel-template-golf-scores.html
http://www.ozgrid.com/search/templates.htm
http://www.onlinepclearning.com/
https://www.youtube.com/user/OnLinePCLearning/featured

Financial Model Template
https://www.youtube.com/results?sear...finance&page=1

Microsoft Excel Cascading Listboxes Tutorial
http://www.youtube.com/watch?v=YAMvLJRwZdI

Date & Time stamping:
http://www.mcgimpsey.com/excel/timestamp.html

Get Formula / Formats thru custom functions:
http://dmcritchie.mvps.org/excel/formula.htm#GetFormat

A nice informative MS article "Improving Performance in Excel 2007"
http://msdn.microsoft.com/en-us/library/aa730921.aspx

Progress Meters
http://www.andypope.info/vba/pmeter.htm
http://www.xcelfiles.com/ProgressBar.html

How to convert text to numbers in Excel
http://support.microsoft.com/kb/291047

How to parse data from the web - Brett Fret has a video in YouTube
http://www.youtube.com/watch?v=6H7tBL97orE

Excel VBA MAC shortcuts
http://www.mrexcel.com/forum/excel-questions/465614-mac-shortcuts-excel.html

http://www.internet4classrooms.com/excel_keyboard_mac.htm
http://office.microsoft.com/en-us/mac-excel-help/excel-keyboard-shortcuts-HA102927337.aspx

http://office.microsoft.com/en-us/excel-help/excel-shortcut-and-function-keys-HP010073848.aspx

Excel VLOOKUP Multiple Sheets • My Online Training Hub

Wise Owl Tutorials
https://www.youtube.com/playlist?list=PLNIs-AWhQzckr8Dgmgb3akx_gFMnpxTN5
https://www.youtube.com/watch?v=KHO5NIcZAc4&feature=youtu.be&list=PLNIs-AWhQzckr8Dgmgb3akx_gFMnpxTN5

http://msdn.microsoft.com/en-us/library/cc837974.aspx
Merging Data from Multiple Workbooks into a Summary Workbook in Excel
Merge data from all workbooks in a folder
Merging a Range from Selected Workbooks
Merging a Range from Multiple Workbooks by Column
Merging a Range from Multiple Workbooks in a Folder with a Filter

You could do a Google search with “You Tube” and use the foollowing names, and/or, links:
https://www.youtube.com/playlist?lis...3akx_gFMnpxTN5
https://www.youtube.com/watch?v=ABXP...S5k4zsvnu2mkJC
https://www.youtube.com/watch?v=KHO5...3akx_gFMnpxTN5
https://www.youtube.com/watch?v=kd6Z...VH5Dq42RG9tlRP
https://www.youtube.com/watch?v=AIhK...suD6oNDaOk3vbR
https://www.youtube.com/watch?v=Z08z...Z_6brD5Gk1sVy_
https://www.youtube.com/user/ExcelVbaIsFun/playlists
https://www.youtube.com/watch?v=o_d8...lhXL_9m7EAgcMq
https://www.youtube.com/user/ExcelVB...ort=dd&view=50
https://www.youtube.com/playlist?lis...o2SEPBLLPGOyBz
https://www.youtube.com/watch?v=y_1e...7lleNVtNeAhBVC
https://www.youtube.com/watch?v=CDYk...007E847B3E6658
https://www.youtube.com/user/ExcelVbaIsFun/videos

Some other Threads where VBA learning was discussed:
Basics of Excel VBA and Code writting
Excel VBA
http://www.excelforum.com/excel-for...-my-macro-is-launched-from-2.html#post4250487
http://www.excelforum.com/excel-general/1111289-how-useful-are-youtube-tutorials-for-vba.html
https://members.excelcampus.com/a/1523/fdzAdugs

Sending mail from Excel with CDO
http://www.rondebruin.nl/win/s1/cdo.htm

And, as your skills increase, try answering threads on sites like:
http://www.mrexcel.com
http://www.excelforum.com
http://www.ozgrid.com
http://www.vbaexpress.com
http://www.excelfox.com

If you are willing to spend money for the training, then something here should work for you...
http://www.amazon.com/s/?ie=UTF8&ke...vpone=&hvptwo=&hvqmt=b&ref=pd_sl_5givffg47i_b

Advanced Excel Training - Online Excel Course
http://www.udemy.com/advanced-excel/

Learn VBA Fast, Vol. I: Excel function design course, with practice exercises (The VBA Function Design Course Book 1)
http://www.amazon.co.uk/dp/B00M6E8MBW

Excel VBA Programmer Interview - Excel Test for interview
http://www.vbaexpress.com/forum/showthread.php?48406-Excel-VBA-Programmer-Interview&

Excel tests
http://www.excel-skills.com/demos2010/skills_test.php
http://www.skills-assessment.net/home/frmIndex.aspx?e=135
https://www.wiziq.com/tests/ms-excel

Here is another Function translator that is extremely popular:
http://en.excel-translator.de/functions/text/
It will also translate Formulas as well
http://en.excel-translator.de/translator/

Here a couple of good blogs on the R1C1 Style Notation
https://smurfonspreadsheets.wordpress.com/2007/11/12/r1c1-notation/
http://powerspreadsheets.com/r1c1-formular1c1-vba/

Top ten ways to clean your data
https://support.office.com/en-us/ar...our-data-a64879eb-115f-4e3d-a3bf-9cfc08a0a4e3

Analytical reasoning test of Excel aptitude
http://www.exceltip.com/wp-content/uploads/2015/07/Download-Top-30-Microsoft-Interview-Questions.pdf

RegEX question - Alpha only upper case only.
Regex Tutorial—From Regex 101 to Advanced Regex
Regular Expression Tutorial - Learn How to Use Regular Expressions
https://www.princeton.edu/~mlovett/r...xpressions.pdf

The VBA Guide To ListObject Excel Tables
https://www.thespreadsheetguru.com/blog/2014/6/20/the-vba-guide-to-listobject-excel-tables

Hiding Macros
https://www.mrexcel.com/forum/excel-questions/1030101-hiding-macros.html

Excel keyboard shortcuts
http://www.asap-utilities.com/excel-tips-shortcuts.php
A nearly complete Microsoft list, from thisoldman:
https://support.office.com/en-us/art...9-9b7213f0040f
This has some that aren't listed on the MS page:
http://www.asap-utilities.com/excel-tips-shortcuts.php
And this one:
https://exceljet.net/keyboard-shortcuts
Microsoft changed some shortcuts between 2003 and 2007 versions and they continue to change them.
Menu shortcuts, get changed too.
If you have a newer version of Excel, type Alt+d and a message will pop up: "Continue typing the menu key sequence ..."
My favorite little known key sequences are the context menu shortcuts.
If you're on Windows with a keyboard that has a menu key, copy a range of cells, then select a destination.
Press the menu key (between Rt-Alt and Rt-Ctrl) then press V to paste values only, or R to paste formats only, or T to transpose+paste.
 
Upvote 0
Dear Fluff,

Thanks for your reply.

If i add the offset code to each paste line it makes a disaster. It copies some, not all, of the desired columns in the new sheet. but it pastes the values of one row in 5 different rows. And it does this only for one row containing today's date. But I would normally have about 50 rows with today's date that need to be copied.

I am pretty desperate as i have tried several changes to the code with no step in the right direction.

Latest code:

Code:
Sub CierreDia()


Sheets("Pacientes y Tratamiento").Select
    
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Dim c As Range
    For Each c In Range("A5:A" & bottomA)
    
        If c = Date Then
            Cells(c.Row, "A").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Cells(c.Row, "B").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Cells(c.Row, "D").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "C").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Cells(c.Row, "E").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "E").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Cells(c.Row, "H").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "K").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Cells(c.Row, "I").Copy
            Sheets("Registro y Hoja de Caja").Cells(Rows.Count, "F").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
        End If
    Next c
    Application.ScreenUpdating = True


End Sub


Here is a link to the workbook if someone wants to take a look at it. I have cleared the names of the patients and left only a couple of pseudo entries.
http://www.prohmex.ch/CENTROS XPLORA 3D_v1_Madrid_test.xlsm

Thank you all for your assistance.
Also a special thanks to hiker95 for all the precious links that will come in very handy in the future!

Best regards
Pascal
 
Upvote 0
OK, try
Code:
Sub CierreDia()


Sheets("Pacientes y Tratamiento").Select
    
    Application.ScreenUpdating = False
    Dim bottomA As Long
    Dim bottomB As Long
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    bottomB = Sheets("Registro y Hoja de Caja").Range("B" & Rows.Count).End(xlUp).Offset(1)
    Dim c As Range
    For Each c In Range("A5:A" & bottomA)
    
        If c = Date Then
            Cells(c.Row, "A").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "B").PasteSpecial xlPasteValues
            Cells(c.Row, "B").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "D").PasteSpecial xlPasteValues
            Cells(c.Row, "D").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "C").PasteSpecial xlPasteValues
            Cells(c.Row, "E").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "E").PasteSpecial xlPasteValues
            Cells(c.Row, "H").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "K").PasteSpecial xlPasteValues
            Cells(c.Row, "I").copy
            Sheets("Registro y Hoja de Caja").Cells(bottomB, "F").PasteSpecial xlPasteValues
        End If
        bottomB = bottomB + 1
    Next c
    Application.ScreenUpdating = True


End Sub
Also the link you supplied doesn't work.
 
Upvote 0
Dear Fluff,

I Have tried your code... it gives me back an Application defined or object defined error (Run-time error '1004') on the first paste line
Code:
Sheets("Registro y Hoja de Caja").Cells(bottomB, "B").PasteSpecial xlPasteValues

As for the link... it is strange as it works for me... it should immediately start the download of the excel file.

try copy paste the link in to your browser.

http://www.prohmex.ch/CENTROS_XPLORA_3D_v1_Madrid_test.xlsm

hope it works.

Thank you so much for your support... wouldn't know what to do without your help!!!

Best regards
Pascal
 
Upvote 0
Apologies add the part in red to this line
Code:
bottomB = Sheets("Registro y Hoja de Caja").Range("B" & Rows.Count).End(xlUp).Offset(1)[COLOR=#ff0000].row[/COLOR]
As for the link, all I see is a page of this
Code:
PK�����!�úMáEq��]���[Content_Types].xml ¢( ������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
ÌXÛrÚ0}ïLÿÁãפmšf€<$éS§ÍLÒò‚UdI£Uü}Wæ ÛÁ3æ_wÏÙ‹�Xõo湊fàP=ˆ{I7Ž@“J=Äž~t®â=×)WFà ^�Æ7Ã�úO‘µÆAœyo¯C‘AÎ114=—sO—nÂ,S>vÑí^2a´í;>øˆ‡ý;ógå£û9Ý^2±zG·Ë÷Ô –y°÷Ù›#©÷,¸µJ
î)46Óé*Ž�¥€ÔˆçœÈ$hð
 
Upvote 0

Forum statistics

Threads
1,223,919
Messages
6,175,368
Members
452,638
Latest member
Oluwabukunmi

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