Link to home
Start Free TrialLog in
Avatar of magento
magento

asked on

Excel - more information

Can some one please help me understand abt the range,cell,rows and the lines below.

  lRow = Range("A" & Rows.Count).End(xlUp).Row
  For each cell in Range("B2:B" & lRow)
    If Range("A" & cel.Row) <> "" Then Range("B1").Copy Destination:=cel
  Next cel
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note in finding last cell with detain column a a1:a10 could be blank but if A11 has data 11 will be the return for loop on B as b1:B11 and B1:B10 would be blank in this instance.

Chris
lRow = Range("A" & Rows.Count).End(xlUp).Row
This line will assing last row number in column-A to 'lRow' variable.

Now, following loop will check for Row2 to lRow in Column-B that if a particular cell in Column-A is not blank then copy corresponding cell from Column-B to cell in Column-A

  For each cell in Range("B2:B" & lRow)
    If Range("A" & cel.Row) <> "" Then Range("B1").Copy Destination:=cel
  Next cel
Sorry for the range 1:10 etc. read 2:10 row 1 is your master data you are copying when required.

Chris
Avatar of magento
magento

ASKER

Can you please let me know the most used objects in vba code?
Most used objects ... I would hesitate to suggest it depends on your application and role for example ranges in excel and record sets in access with a smidgins of mail item in outlook, shape in ppt.

The list could be endless but scoping to your code range and excel!

Chris
My answer is not directly to the point, but may give you hints an idea's for different ways to complete your entire 'project'.
Your code explained in worksheet operation would be this:

in B2 you type: =if(A2="","","$B$1)

Then you fill down the formula to the last filled cell in column A.

The advantage of working with formula's in this case is that you have immediate and automatic result.

Regards,
Davy
Avatar of magento

ASKER

Thanks Chris
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.