Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Cell references

0

I'm trying to get a date entered into A1 on Tab 1 be automatically entered into A1 Tab 2. I can get it to automatically fill in the date in Tab 2 but if I change the position of A1 in Tab 1 (sorting) the data in A1 Tab 2 changes to the data which is now in A1 Tab 1.

I've tried all the configurations of cell references both absolute, relative or mixed.

I can't seem to get this figured out. Thanks for your help.

Answer
Discuss

Answers

0

In Excel Sheet1!A1 is a fixed address. You can refer to that address in Sheet2!A1 and you will see in Sheet2!A1 whatever is currently in Sheet1!A1 - as you have found out. I am repeating the principle because you can use it to your advantage.

In this case, however, you don't want the value in Sheet1!A1. Instead, there is a value elsewhere in Rows(1) to which the date is related. You wish to preserve this relationship, and that gives you a clue to the answer.

Say, you have a date and and order number. What you want tin Sheet2 is the date that does with the order number, regardless of where it appears in Sheet1. To achieve this you need a unique value (such as an order number) which appears in both sheets. You can then use a number of options to retrieve that date by looking for the order number.

The most commonly used one would be VLOOKUP() but that would require that the lookup value (the order number) be to the left of the date which wouldn't be possible if the date is in Columns("A"). You might look at the Index/Match combination if the arrangement on your sheet is really unsuitable for VLOOKUP(). 

Discuss

Discussion

I think I presented this incorrectly. I have a workbook multiple spreadsheets. One sheet has all the recor) and the same data is in separate sheets by unit. I want to be able,to fill in a date in one of the unit sheets and automatically populate the,matching record,in the. overall sheet when match3d by ID#. I've named the cells to prevent values changing when sorting.

This is the syntax I used--

=if(cnum1=cnum2, compdate1=compdate2,"")

So I'm trying to get the compdate2 entered in sheet 2 into compdate1 sheet 1 if the values in cnum1 = cnum2 or leave it blank.

Thanks for any help you can give.
ie12041952 Sep 8, '17 at 10:56 am
I would have to see the workbook in order to proceed further. Perhaps you can prepare a workbook with reduced and mock-up data for publication here.
Variatus (rep: 4889) Sep 8, '17 at 9:54 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login